Lines Matching defs:bio

5 #include <linux/bio.h>
135 struct bio *bio;
163 int __must_check submit_one_bio(struct bio *bio, int mirror_num,
167 struct extent_io_tree *tree = bio->bi_private;
169 bio->bi_private = NULL;
172 ret = btrfs_submit_data_bio(tree->private_data, bio, mirror_num,
175 ret = btrfs_submit_metadata_bio(tree->private_data, bio,
184 if (epd->bio) {
185 epd->bio->bi_status = errno_to_blk_status(ret);
186 bio_endio(epd->bio);
187 epd->bio = NULL;
192 * Submit bio from extent page data via submit_one_bio
201 if (epd->bio) {
202 ret = submit_one_bio(epd->bio, 0, 0);
204 * Clean up of epd->bio is handled by its endio function.
205 * And endio is either triggered by successful bio execution
206 * or the error handler of submit bio hook.
208 * to clean up epd->bio.
210 epd->bio = NULL;
234 offsetof(struct btrfs_io_bio, bio),
2257 struct bio *bio;
2267 bio = btrfs_io_bio_alloc(1);
2268 bio->bi_iter.bi_size = 0;
2288 bio_put(bio);
2297 bio_put(bio);
2304 bio->bi_iter.bi_sector = sector;
2310 bio_put(bio);
2313 bio_set_dev(bio, dev->bdev);
2314 bio->bi_opf = REQ_OP_WRITE | REQ_SYNC;
2315 bio_add_page(bio, page, length, pg_offset);
2317 if (btrfsic_submit_bio_wait(bio)) {
2320 bio_put(bio);
2330 bio_put(bio);
2565 * we need separate read requests for the failed bio
2600 static bool btrfs_io_needs_validation(struct inode *inode, struct bio *bio)
2610 if (bio->bi_status == BLK_STS_OK)
2618 * 1. A buffered read bio, which is not cloned.
2619 * 2. A direct I/O read bio, which is cloned.
2620 * 3. A (buffered or direct) repair bio, which is not cloned.
2626 if (bio_flagged(bio, BIO_CLONED)) {
2627 if (btrfs_io_bio(bio)->iter.bi_size > blocksize)
2633 bio_for_each_bvec_all(bvec, bio, i) {
2643 struct bio *failed_bio, u64 phy_offset,
2655 struct bio *repair_bio;
2736 static void end_bio_extent_writepage(struct bio *bio)
2738 int error = blk_status_to_errno(bio->bi_status);
2744 ASSERT(!bio_flagged(bio, BIO_CLONED));
2745 bio_for_each_segment_all(bvec, bio, iter_all) {
2773 bio_put(bio);
2799 static void end_bio_extent_readpage(struct bio *bio)
2802 int uptodate = !bio->bi_status;
2803 struct btrfs_io_bio *io_bio = btrfs_io_bio(bio);
2815 ASSERT(!bio_flagged(bio, BIO_CLONED));
2816 bio_for_each_segment_all(bvec, bio, iter_all) {
2823 (u64)bio->bi_iter.bi_sector, bio->bi_status,
2876 * 0 and we just go on with the next page in our bio.
2880 if (!btrfs_submit_read_repair(inode, bio, offset, page,
2884 uptodate = !bio->bi_status;
2944 bio_put(bio);
2948 * Initialize the members up to but not including 'bio'. Use after allocating a
2949 * new bio by bio_alloc_bioset as it does not initialize the bytes outside of
2950 * 'bio' because use of __GFP_ZERO is not supported.
2954 memset(btrfs_bio, 0, offsetof(struct btrfs_io_bio, bio));
2958 * The following helpers allocate a bio. As it's backed by a bioset, it'll
2959 * never fail. We're returning a bio right now but you can call btrfs_io_bio
2962 struct bio *btrfs_bio_alloc(u64 first_byte)
2964 struct bio *bio;
2966 bio = bio_alloc_bioset(GFP_NOFS, BIO_MAX_PAGES, &btrfs_bioset);
2967 bio->bi_iter.bi_sector = first_byte >> 9;
2968 btrfs_io_bio_init(btrfs_io_bio(bio));
2969 return bio;
2972 struct bio *btrfs_bio_clone(struct bio *bio)
2975 struct bio *new;
2978 new = bio_clone_fast(bio, GFP_NOFS, &btrfs_bioset);
2981 btrfs_bio->iter = bio->bi_iter;
2985 struct bio *btrfs_io_bio_alloc(unsigned int nr_iovecs)
2987 struct bio *bio;
2990 bio = bio_alloc_bioset(GFP_NOFS, nr_iovecs, &btrfs_bioset);
2991 btrfs_io_bio_init(btrfs_io_bio(bio));
2992 return bio;
2995 struct bio *btrfs_bio_clone_partial(struct bio *orig, int offset, int size)
2997 struct bio *bio;
3001 bio = bio_clone_fast(orig, GFP_NOFS, &btrfs_bioset);
3002 ASSERT(bio);
3004 btrfs_bio = btrfs_io_bio(bio);
3007 bio_trim(bio, offset >> 9, size >> 9);
3008 btrfs_bio->iter = bio->bi_iter;
3009 return bio;
3013 * @opf: bio REQ_OP_* and REQ_* flags as one value
3015 * @page: page to add to the bio
3016 * @pg_offset: offset of the new bio or to check whether we are adding
3020 * @bio_ret: must be valid pointer, newly allocated bio will be stored there
3021 * @end_io_func: end_io callback for new bio
3023 * @prev_bio_flags: flags of previous bio to see if we can merge the current one
3024 * @bio_flags: flags of the current bio to see if we can merge them
3030 struct bio **bio_ret,
3038 struct bio *bio;
3049 bio = *bio_ret;
3051 contig = bio->bi_iter.bi_sector == sector;
3053 contig = bio_end_sector(bio) == sector;
3055 if (btrfs_bio_fits_in_stripe(page, page_size, bio, bio_flags))
3060 bio_add_page(bio, page, page_size, pg_offset) < page_size) {
3061 ret = submit_one_bio(bio, mirror_num, prev_bio_flags);
3066 bio = NULL;
3074 bio = btrfs_bio_alloc(offset);
3075 bio_add_page(bio, page, page_size, pg_offset);
3076 bio->bi_end_io = end_io_func;
3077 bio->bi_private = tree;
3078 bio->bi_write_hint = page->mapping->host->i_write_hint;
3079 bio->bi_opf = opf;
3084 bio_set_dev(bio, bdev);
3085 wbc_init_bio(wbc, bio);
3089 *bio_ret = bio;
3143 struct bio **bio, unsigned long *bio_flags,
3242 * single bio to populate the pages for the 2 ranges because
3255 * If the bio to read the compressed extent covers both ranges,
3262 * make the compressed bio endio callback populate the pages
3263 * for both ranges because each compressed bio is tightly
3321 pg_offset, bio,
3349 struct bio **bio,
3359 btrfs_do_readpage(pages[index], em_cached, bio, bio_flags,
3549 &epd->bio,
3657 * Lock eb pages and flush the bio if we can't the locks
3660 * Return >0 is same as 0, except bio is not submitted
3839 static void end_bio_extent_buffer_writepage(struct bio *bio)
3846 ASSERT(!bio_flagged(bio, BIO_CLONED));
3847 bio_for_each_segment_all(bvec, bio, iter_all) {
3854 if (bio->bi_status ||
3868 bio_put(bio);
3909 &epd->bio,
3942 .bio = NULL,
4062 * If something went wrong, don't allow any metadata write bio to be
4245 * page in our current bio, and thus deadlock, so flush the
4246 * write bio here.
4264 .bio = NULL,
4291 .bio = NULL,
4334 .bio = NULL,
4351 struct bio *bio = NULL;
4365 &em_cached, &bio, &bio_flags, &prev_em_start);
4371 if (bio) {
4372 if (submit_one_bio(bio, 0, bio_flags))
5496 struct bio *bio = NULL;
5552 &bio, end_bio_extent_readpage,
5556 * We failed to submit the bio so it's the
5570 if (bio) {
5571 err = submit_one_bio(bio, mirror_num, bio_flags);