struct bio *bio;
        int ret;
 
-       bio = btrfs_bio_alloc(BIO_MAX_VECS);
-
+       bio = btrfs_bio_alloc(BIO_MAX_VECS, opf);
        bio->bi_iter.bi_sector = disk_bytenr >> SECTOR_SHIFT;
-       bio->bi_opf = opf;
        bio->bi_private = cb;
        bio->bi_end_io = endio_func;
 
 
                return -EIO;
        }
 
-       repair_bio = btrfs_bio_alloc(1);
+       repair_bio = btrfs_bio_alloc(1, REQ_OP_READ);
        repair_bbio = btrfs_bio(repair_bio);
        repair_bbio->file_offset = start;
-       repair_bio->bi_opf = REQ_OP_READ;
        repair_bio->bi_end_io = failed_bio->bi_end_io;
        repair_bio->bi_iter.bi_sector = failrec->logical >> 9;
        repair_bio->bi_private = failed_bio->bi_private;
        struct bio *bio;
        int ret;
 
-       bio = btrfs_bio_alloc(BIO_MAX_VECS);
+       bio = btrfs_bio_alloc(BIO_MAX_VECS, opf);
        /*
         * For compressed page range, its disk_bytenr is always @disk_bytenr
         * passed in, no matter if we have added any range into previous bio.
        bio_ctrl->bio = bio;
        bio_ctrl->compress_type = compress_type;
        bio->bi_end_io = end_io_func;
-       bio->bi_opf = opf;
        ret = calc_bio_boundaries(bio_ctrl, inode, file_offset);
        if (ret < 0)
                goto error;
 
                        size_t bytes = min_t(u64, remaining, PAGE_SIZE);
 
                        if (!bio) {
-                               bio = btrfs_bio_alloc(BIO_MAX_VECS);
+                               bio = btrfs_bio_alloc(BIO_MAX_VECS, REQ_OP_READ);
                                bio->bi_iter.bi_sector =
                                        (disk_bytenr + cur) >> SECTOR_SHIFT;
                                bio->bi_end_io = btrfs_encoded_read_endio;
                                bio->bi_private = &priv;
-                               bio->bi_opf = REQ_OP_READ;
                        }
 
                        if (!bytes ||
 
  * Just like the underlying bio_alloc_bioset it will not fail as it is backed by
  * a mempool.
  */
-struct bio *btrfs_bio_alloc(unsigned int nr_vecs)
+struct bio *btrfs_bio_alloc(unsigned int nr_vecs, blk_opf_t opf)
 {
        struct bio *bio;
 
-       bio = bio_alloc_bioset(NULL, nr_vecs, 0, GFP_NOFS, &btrfs_bioset);
+       bio = bio_alloc_bioset(NULL, nr_vecs, opf, GFP_NOFS, &btrfs_bioset);
        btrfs_bio_init(btrfs_bio(bio));
        return bio;
 }
 
 int __init btrfs_bioset_init(void);
 void __cold btrfs_bioset_exit(void);
 
-struct bio *btrfs_bio_alloc(unsigned int nr_vecs);
+struct bio *btrfs_bio_alloc(unsigned int nr_vecs, blk_opf_t opf);
 struct bio *btrfs_bio_clone_partial(struct bio *orig, u64 offset, u64 size);
 
 static inline void btrfs_bio_free_csum(struct btrfs_bio *bbio)