Lines Matching refs:bio
38 return is_data_bbio(bbio) && btrfs_op(&bbio->bio) == BTRFS_MAP_WRITE; in bbio_has_ordered_extent()
48 memset(bbio, 0, offsetof(struct btrfs_bio, bio)); in btrfs_bio_init()
67 struct bio *bio; in btrfs_bio_alloc() local
69 bio = bio_alloc_bioset(NULL, nr_vecs, opf, GFP_NOFS, &btrfs_bioset); in btrfs_bio_alloc()
70 bbio = btrfs_bio(bio); in btrfs_bio_alloc()
80 struct bio *bio; in btrfs_split_bio() local
85 bio = bio_split_rw(&orig_bbio->bio, &fs_info->limits, &nr_segs, in btrfs_split_bio()
88 bio = bio_split(&orig_bbio->bio, map_length >> SECTOR_SHIFT, in btrfs_split_bio()
91 bbio = btrfs_bio(bio); in btrfs_split_bio()
109 bio_put(&bbio->bio); in btrfs_cleanup_bio()
126 bbio->bio.bi_status = status; in btrfs_bio_end_io()
130 static void btrfs_orig_write_end_io(struct bio *bio);
141 if (bbio->bio.bi_end_io == &btrfs_orig_write_end_io) { in btrfs_bbio_propagate_error()
142 struct btrfs_io_stripe *orig_stripe = orig_bbio->bio.bi_private; in btrfs_bbio_propagate_error()
147 orig_bbio->bio.bi_status = bbio->bio.bi_status; in btrfs_bbio_propagate_error()
153 if (bbio->bio.bi_pool == &btrfs_clone_bioset) { in btrfs_orig_bbio_end_io()
156 if (bbio->bio.bi_status) in btrfs_orig_bbio_end_io()
194 struct bio_vec *bv = bio_first_bvec_all(&repair_bbio->bio); in btrfs_end_repair_bio()
197 if (repair_bbio->bio.bi_status || in btrfs_end_repair_bio()
199 bio_reset(&repair_bbio->bio, NULL, REQ_OP_READ); in btrfs_end_repair_bio()
200 repair_bbio->bio.bi_iter = repair_bbio->saved_iter; in btrfs_end_repair_bio()
205 fbio->bbio->bio.bi_status = BLK_STS_IOERR; in btrfs_end_repair_bio()
223 bio_put(&repair_bbio->bio); in btrfs_end_repair_bio()
243 struct bio *repair_bio; in repair_one_sector()
253 failed_bbio->bio.bi_status = BLK_STS_IOERR; in repair_one_sector()
288 blk_status_t status = bbio->bio.bi_status; in btrfs_check_read_bio()
299 if (bbio->bio.bi_pool == &btrfs_repair_bioset) { in btrfs_check_read_bio()
305 bbio->bio.bi_status = BLK_STS_OK; in btrfs_check_read_bio()
308 struct bio_vec bv = bio_iter_iovec(&bbio->bio, *iter); in btrfs_check_read_bio()
314 bio_advance_iter_single(&bbio->bio, iter, sectorsize); in btrfs_check_read_bio()
327 static void btrfs_log_dev_io_error(struct bio *bio, struct btrfs_device *dev) in btrfs_log_dev_io_error() argument
331 if (bio->bi_status != BLK_STS_IOERR && bio->bi_status != BLK_STS_TARGET) in btrfs_log_dev_io_error()
334 if (btrfs_op(bio) == BTRFS_MAP_WRITE) in btrfs_log_dev_io_error()
336 else if (!(bio->bi_opf & REQ_RAHEAD)) in btrfs_log_dev_io_error()
338 if (bio->bi_opf & REQ_PREFLUSH) in btrfs_log_dev_io_error()
343 struct bio *bio) in btrfs_end_io_wq() argument
345 if (bio->bi_opf & REQ_META) in btrfs_end_io_wq()
356 btrfs_check_read_bio(bbio, bbio->bio.bi_private); in btrfs_end_bio_work()
361 static void btrfs_simple_end_io(struct bio *bio) in btrfs_simple_end_io() argument
363 struct btrfs_bio *bbio = btrfs_bio(bio); in btrfs_simple_end_io()
364 struct btrfs_device *dev = bio->bi_private; in btrfs_simple_end_io()
369 if (bio->bi_status) in btrfs_simple_end_io()
370 btrfs_log_dev_io_error(bio, dev); in btrfs_simple_end_io()
372 if (bio_op(bio) == REQ_OP_READ) { in btrfs_simple_end_io()
374 queue_work(btrfs_end_io_wq(fs_info, bio), &bbio->end_io_work); in btrfs_simple_end_io()
376 if (bio_op(bio) == REQ_OP_ZONE_APPEND && !bio->bi_status) in btrfs_simple_end_io()
382 static void btrfs_raid56_end_io(struct bio *bio) in btrfs_raid56_end_io() argument
384 struct btrfs_io_context *bioc = bio->bi_private; in btrfs_raid56_end_io()
385 struct btrfs_bio *bbio = btrfs_bio(bio); in btrfs_raid56_end_io()
389 if (bio_op(bio) == REQ_OP_READ && is_data_bbio(bbio)) in btrfs_raid56_end_io()
397 static void btrfs_orig_write_end_io(struct bio *bio) in btrfs_orig_write_end_io() argument
399 struct btrfs_io_stripe *stripe = bio->bi_private; in btrfs_orig_write_end_io()
401 struct btrfs_bio *bbio = btrfs_bio(bio); in btrfs_orig_write_end_io()
405 if (bio->bi_status) { in btrfs_orig_write_end_io()
407 btrfs_log_dev_io_error(bio, stripe->dev); in btrfs_orig_write_end_io()
415 bio->bi_status = BLK_STS_IOERR; in btrfs_orig_write_end_io()
417 bio->bi_status = BLK_STS_OK; in btrfs_orig_write_end_io()
423 static void btrfs_clone_write_end_io(struct bio *bio) in btrfs_clone_write_end_io() argument
425 struct btrfs_io_stripe *stripe = bio->bi_private; in btrfs_clone_write_end_io()
427 if (bio->bi_status) { in btrfs_clone_write_end_io()
429 btrfs_log_dev_io_error(bio, stripe->dev); in btrfs_clone_write_end_io()
434 bio_put(bio); in btrfs_clone_write_end_io()
437 static void btrfs_submit_dev_bio(struct btrfs_device *dev, struct bio *bio) in btrfs_submit_dev_bio() argument
441 (btrfs_op(bio) == BTRFS_MAP_WRITE && in btrfs_submit_dev_bio()
443 bio_io_error(bio); in btrfs_submit_dev_bio()
447 bio_set_dev(bio, dev->bdev); in btrfs_submit_dev_bio()
453 if (bio_op(bio) == REQ_OP_ZONE_APPEND) { in btrfs_submit_dev_bio()
454 u64 physical = bio->bi_iter.bi_sector << SECTOR_SHIFT; in btrfs_submit_dev_bio()
458 bio->bi_iter.bi_sector = zone_start >> SECTOR_SHIFT; in btrfs_submit_dev_bio()
462 __func__, bio_op(bio), bio->bi_opf, bio->bi_iter.bi_sector, in btrfs_submit_dev_bio()
464 dev->devid, bio->bi_iter.bi_size); in btrfs_submit_dev_bio()
466 btrfsic_check_bio(bio); in btrfs_submit_dev_bio()
468 if (bio->bi_opf & REQ_BTRFS_CGROUP_PUNT) in btrfs_submit_dev_bio()
469 blkcg_punt_bio_submit(bio); in btrfs_submit_dev_bio()
471 submit_bio(bio); in btrfs_submit_dev_bio()
476 struct bio *orig_bio = bioc->orig_bio, *bio; in btrfs_submit_mirrored_bio() local
482 bio = orig_bio; in btrfs_submit_mirrored_bio()
483 bio->bi_end_io = btrfs_orig_write_end_io; in btrfs_submit_mirrored_bio()
485 bio = bio_alloc_clone(NULL, orig_bio, GFP_NOFS, &fs_bio_set); in btrfs_submit_mirrored_bio()
487 bio->bi_end_io = btrfs_clone_write_end_io; in btrfs_submit_mirrored_bio()
490 bio->bi_private = &bioc->stripes[dev_nr]; in btrfs_submit_mirrored_bio()
491 bio->bi_iter.bi_sector = bioc->stripes[dev_nr].physical >> SECTOR_SHIFT; in btrfs_submit_mirrored_bio()
493 btrfs_submit_dev_bio(bioc->stripes[dev_nr].dev, bio); in btrfs_submit_mirrored_bio()
496 static void __btrfs_submit_bio(struct bio *bio, struct btrfs_io_context *bioc, in __btrfs_submit_bio() argument
501 btrfs_bio(bio)->mirror_num = mirror_num; in __btrfs_submit_bio()
502 bio->bi_iter.bi_sector = smap->physical >> SECTOR_SHIFT; in __btrfs_submit_bio()
503 if (bio_op(bio) != REQ_OP_READ) in __btrfs_submit_bio()
504 btrfs_bio(bio)->orig_physical = smap->physical; in __btrfs_submit_bio()
505 bio->bi_private = smap->dev; in __btrfs_submit_bio()
506 bio->bi_end_io = btrfs_simple_end_io; in __btrfs_submit_bio()
507 btrfs_submit_dev_bio(smap->dev, bio); in __btrfs_submit_bio()
510 bio->bi_private = bioc; in __btrfs_submit_bio()
511 bio->bi_end_io = btrfs_raid56_end_io; in __btrfs_submit_bio()
512 if (bio_op(bio) == REQ_OP_READ) in __btrfs_submit_bio()
513 raid56_parity_recover(bio, bioc, mirror_num); in __btrfs_submit_bio()
515 raid56_parity_write(bio, bioc); in __btrfs_submit_bio()
520 bioc->orig_bio = bio; in __btrfs_submit_bio()
528 if (bbio->bio.bi_opf & REQ_META) in btrfs_bio_csum()
561 async->bbio->bio.bi_status = ret; in run_one_async_start()
576 struct bio *bio = &async->bbio->bio; in run_one_async_done() local
579 if (bio->bi_status) { in run_one_async_done()
589 bio->bi_opf |= REQ_BTRFS_CGROUP_PUNT; in run_one_async_done()
590 __btrfs_submit_bio(bio, async->bioc, &async->smap, async->mirror_num); in run_one_async_done()
608 if (op_is_sync(bbio->bio.bi_opf)) in should_async_write()
612 if ((bbio->bio.bi_opf & REQ_META) && btrfs_is_zoned(bbio->fs_info)) in should_async_write()
650 struct bio *bio = &bbio->bio; in btrfs_submit_chunk() local
651 u64 logical = bio->bi_iter.bi_sector << SECTOR_SHIFT; in btrfs_submit_chunk()
652 u64 length = bio->bi_iter.bi_size; in btrfs_submit_chunk()
661 error = btrfs_map_block(fs_info, btrfs_op(bio), logical, &map_length, in btrfs_submit_chunk()
674 bio = &bbio->bio; in btrfs_submit_chunk()
681 if (bio_op(bio) == REQ_OP_READ && is_data_bbio(bbio)) { in btrfs_submit_chunk()
682 bbio->saved_iter = bio->bi_iter; in btrfs_submit_chunk()
688 if (btrfs_op(bio) == BTRFS_MAP_WRITE) { in btrfs_submit_chunk()
690 bio->bi_opf &= ~REQ_OP_WRITE; in btrfs_submit_chunk()
691 bio->bi_opf |= REQ_OP_ZONE_APPEND; in btrfs_submit_chunk()
715 __btrfs_submit_bio(bio, bioc, &smap, mirror_num); in btrfs_submit_chunk()
754 struct bio bio; in btrfs_repair_io_failure() local
779 bio_init(&bio, smap.dev->bdev, &bvec, 1, REQ_OP_WRITE | REQ_SYNC); in btrfs_repair_io_failure()
780 bio.bi_iter.bi_sector = smap.physical >> SECTOR_SHIFT; in btrfs_repair_io_failure()
781 __bio_add_page(&bio, page, length, pg_offset); in btrfs_repair_io_failure()
783 btrfsic_check_bio(&bio); in btrfs_repair_io_failure()
784 ret = submit_bio_wait(&bio); in btrfs_repair_io_failure()
798 bio_uninit(&bio); in btrfs_repair_io_failure()
812 u64 logical = bbio->bio.bi_iter.bi_sector << SECTOR_SHIFT; in btrfs_submit_repair_write()
813 u64 length = bbio->bio.bi_iter.bi_size; in btrfs_submit_repair_write()
819 ASSERT(btrfs_op(&bbio->bio) == BTRFS_MAP_WRITE); in btrfs_submit_repair_write()
831 __btrfs_submit_bio(&bbio->bio, NULL, &smap, mirror_num); in btrfs_submit_repair_write()
842 offsetof(struct btrfs_bio, bio), in btrfs_bioset_init()
846 offsetof(struct btrfs_bio, bio), 0)) in btrfs_bioset_init()
849 offsetof(struct btrfs_bio, bio), in btrfs_bioset_init()