Lines Matching refs:bio

7 #include <linux/bio.h>
8 #include "bio.h"
38 return is_data_bbio(bbio) && btrfs_op(&bbio->bio) == BTRFS_MAP_WRITE;
42 * Initialize a btrfs_bio structure. This skips the embedded bio itself as it
48 memset(bbio, 0, offsetof(struct btrfs_bio, bio));
67 struct bio *bio;
69 bio = bio_alloc_bioset(NULL, nr_vecs, opf, GFP_NOFS, &btrfs_bioset);
70 bbio = btrfs_bio(bio);
80 struct bio *bio;
85 bio = bio_split_rw(&orig_bbio->bio, &fs_info->limits, &nr_segs,
88 bio = bio_split(&orig_bbio->bio, map_length >> SECTOR_SHIFT,
91 bbio = btrfs_bio(bio);
104 /* Free a bio that was never submitted to the underlying device. */
109 bio_put(&bbio->bio);
126 bbio->bio.bi_status = status;
130 static void btrfs_orig_write_end_io(struct bio *bio);
141 if (bbio->bio.bi_end_io == &btrfs_orig_write_end_io) {
142 struct btrfs_io_stripe *orig_stripe = orig_bbio->bio.bi_private;
147 orig_bbio->bio.bi_status = bbio->bio.bi_status;
153 if (bbio->bio.bi_pool == &btrfs_clone_bioset) {
156 if (bbio->bio.bi_status)
194 struct bio_vec *bv = bio_first_bvec_all(&repair_bbio->bio);
197 if (repair_bbio->bio.bi_status ||
199 bio_reset(&repair_bbio->bio, NULL, REQ_OP_READ);
200 repair_bbio->bio.bi_iter = repair_bbio->saved_iter;
205 fbio->bbio->bio.bi_status = BLK_STS_IOERR;
223 bio_put(&repair_bbio->bio);
243 struct bio *repair_bio;
253 failed_bbio->bio.bi_status = BLK_STS_IOERR;
288 blk_status_t status = bbio->bio.bi_status;
299 if (bbio->bio.bi_pool == &btrfs_repair_bioset) {
305 bbio->bio.bi_status = BLK_STS_OK;
308 struct bio_vec bv = bio_iter_iovec(&bbio->bio, *iter);
314 bio_advance_iter_single(&bbio->bio, iter, sectorsize);
327 static void btrfs_log_dev_io_error(struct bio *bio, struct btrfs_device *dev)
331 if (bio->bi_status != BLK_STS_IOERR && bio->bi_status != BLK_STS_TARGET)
334 if (btrfs_op(bio) == BTRFS_MAP_WRITE)
336 else if (!(bio->bi_opf & REQ_RAHEAD))
338 if (bio->bi_opf & REQ_PREFLUSH)
343 struct bio *bio)
345 if (bio->bi_opf & REQ_META)
356 btrfs_check_read_bio(bbio, bbio->bio.bi_private);
361 static void btrfs_simple_end_io(struct bio *bio)
363 struct btrfs_bio *bbio = btrfs_bio(bio);
364 struct btrfs_device *dev = bio->bi_private;
369 if (bio->bi_status)
370 btrfs_log_dev_io_error(bio, dev);
372 if (bio_op(bio) == REQ_OP_READ) {
374 queue_work(btrfs_end_io_wq(fs_info, bio), &bbio->end_io_work);
376 if (bio_op(bio) == REQ_OP_ZONE_APPEND && !bio->bi_status)
382 static void btrfs_raid56_end_io(struct bio *bio)
384 struct btrfs_io_context *bioc = bio->bi_private;
385 struct btrfs_bio *bbio = btrfs_bio(bio);
389 if (bio_op(bio) == REQ_OP_READ && is_data_bbio(bbio))
397 static void btrfs_orig_write_end_io(struct bio *bio)
399 struct btrfs_io_stripe *stripe = bio->bi_private;
401 struct btrfs_bio *bbio = btrfs_bio(bio);
405 if (bio->bi_status) {
407 btrfs_log_dev_io_error(bio, stripe->dev);
415 bio->bi_status = BLK_STS_IOERR;
417 bio->bi_status = BLK_STS_OK;
423 static void btrfs_clone_write_end_io(struct bio *bio)
425 struct btrfs_io_stripe *stripe = bio->bi_private;
427 if (bio->bi_status) {
429 btrfs_log_dev_io_error(bio, stripe->dev);
432 /* Pass on control to the original bio this one was cloned from */
434 bio_put(bio);
437 static void btrfs_submit_dev_bio(struct btrfs_device *dev, struct bio *bio)
441 (btrfs_op(bio) == BTRFS_MAP_WRITE &&
443 bio_io_error(bio);
447 bio_set_dev(bio, dev->bdev);
453 if (bio_op(bio) == REQ_OP_ZONE_APPEND) {
454 u64 physical = bio->bi_iter.bi_sector << SECTOR_SHIFT;
458 bio->bi_iter.bi_sector = zone_start >> SECTOR_SHIFT;
462 __func__, bio_op(bio), bio->bi_opf, bio->bi_iter.bi_sector,
464 dev->devid, bio->bi_iter.bi_size);
466 btrfsic_check_bio(bio);
468 if (bio->bi_opf & REQ_BTRFS_CGROUP_PUNT)
469 blkcg_punt_bio_submit(bio);
471 submit_bio(bio);
476 struct bio *orig_bio = bioc->orig_bio, *bio;
480 /* Reuse the bio embedded into the btrfs_bio for the last mirror */
482 bio = orig_bio;
483 bio->bi_end_io = btrfs_orig_write_end_io;
485 bio = bio_alloc_clone(NULL, orig_bio, GFP_NOFS, &fs_bio_set);
487 bio->bi_end_io = btrfs_clone_write_end_io;
490 bio->bi_private = &bioc->stripes[dev_nr];
491 bio->bi_iter.bi_sector = bioc->stripes[dev_nr].physical >> SECTOR_SHIFT;
493 btrfs_submit_dev_bio(bioc->stripes[dev_nr].dev, bio);
496 static void __btrfs_submit_bio(struct bio *bio, struct btrfs_io_context *bioc,
501 btrfs_bio(bio)->mirror_num = mirror_num;
502 bio->bi_iter.bi_sector = smap->physical >> SECTOR_SHIFT;
503 if (bio_op(bio) != REQ_OP_READ)
504 btrfs_bio(bio)->orig_physical = smap->physical;
505 bio->bi_private = smap->dev;
506 bio->bi_end_io = btrfs_simple_end_io;
507 btrfs_submit_dev_bio(smap->dev, bio);
510 bio->bi_private = bioc;
511 bio->bi_end_io = btrfs_raid56_end_io;
512 if (bio_op(bio) == REQ_OP_READ)
513 raid56_parity_recover(bio, bioc, mirror_num);
515 raid56_parity_write(bio, bioc);
520 bioc->orig_bio = bio;
528 if (bbio->bio.bi_opf & REQ_META)
547 * until bio submission time. All the pages in the bio are checksummed and
561 async->bbio->bio.bi_status = ret;
566 * until bio submission time. All the pages in the bio are checksummed and
576 struct bio *bio = &async->bbio->bio;
578 /* If an error occurred we just want to clean up the bio and move on. */
579 if (bio->bi_status) {
589 bio->bi_opf |= REQ_BTRFS_CGROUP_PUNT;
590 __btrfs_submit_bio(bio, async->bioc, &async->smap, async->mirror_num);
608 if (op_is_sync(bbio->bio.bi_opf))
612 if ((bbio->bio.bi_opf & REQ_META) && btrfs_is_zoned(bbio->fs_info))
619 * Submit bio to an async queue.
650 struct bio *bio = &bbio->bio;
651 u64 logical = bio->bi_iter.bi_sector << SECTOR_SHIFT;
652 u64 length = bio->bi_iter.bi_size;
661 error = btrfs_map_block(fs_info, btrfs_op(bio), logical, &map_length,
674 bio = &bbio->bio;
681 if (bio_op(bio) == REQ_OP_READ && is_data_bbio(bbio)) {
682 bbio->saved_iter = bio->bi_iter;
688 if (btrfs_op(bio) == BTRFS_MAP_WRITE) {
690 bio->bi_opf &= ~REQ_OP_WRITE;
691 bio->bi_opf |= REQ_OP_ZONE_APPEND;
715 __btrfs_submit_bio(bio, bioc, &smap, mirror_num);
743 * mapping ourselves and submit the bio directly.
746 * freeing the bio.
754 struct bio bio;
779 bio_init(&bio, smap.dev->bdev, &bvec, 1, REQ_OP_WRITE | REQ_SYNC);
780 bio.bi_iter.bi_sector = smap.physical >> SECTOR_SHIFT;
781 __bio_add_page(&bio, page, length, pg_offset);
783 btrfsic_check_bio(&bio);
784 ret = submit_bio_wait(&bio);
798 bio_uninit(&bio);
812 u64 logical = bbio->bio.bi_iter.bi_sector << SECTOR_SHIFT;
813 u64 length = bbio->bio.bi_iter.bi_size;
819 ASSERT(btrfs_op(&bbio->bio) == BTRFS_MAP_WRITE);
831 __btrfs_submit_bio(&bbio->bio, NULL, &smap, mirror_num);
842 offsetof(struct btrfs_bio, bio),
846 offsetof(struct btrfs_bio, bio), 0))
849 offsetof(struct btrfs_bio, bio),