]> git.baikalelectronics.ru Git - kernel.git/commitdiff
block: pass a block_device and opf to bio_init
authorChristoph Hellwig <hch@lst.de>
Mon, 24 Jan 2022 09:11:06 +0000 (10:11 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 2 Feb 2022 14:49:59 +0000 (07:49 -0700)
Pass the block_device that we plan to use this bio for and the
operation to bio_init to optimize the assignment.  A NULL block_device
can be passed, both for the passthrough case on a raw request_queue and
to temporarily avoid refactoring some nasty code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20220124091107.642561-19-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
26 files changed:
block/bio.c
block/blk-flush.c
block/blk-zoned.c
block/fops.c
drivers/block/floppy.c
drivers/block/zram/zram_drv.c
drivers/md/bcache/io.c
drivers/md/bcache/journal.c
drivers/md/bcache/movinggc.c
drivers/md/bcache/request.c
drivers/md/bcache/super.c
drivers/md/bcache/writeback.c
drivers/md/dm.c
drivers/md/md-multipath.c
drivers/md/md.c
drivers/md/raid5-cache.c
drivers/md/raid5-ppl.c
drivers/md/raid5.c
drivers/nvme/target/io-cmd-bdev.c
drivers/nvme/target/passthru.c
drivers/nvme/target/zns.c
fs/iomap/buffered-io.c
fs/xfs/xfs_bio_io.c
fs/xfs/xfs_log.c
fs/zonefs/super.c
include/linux/bio.h

index b73c9babd58353ccc981a94e761c36d7652aca9e..b2133d86e885ecdad780325bb5eba435b875540b 100644 (file)
@@ -249,12 +249,12 @@ static void bio_free(struct bio *bio)
  * they must remember to pair any call to bio_init() with bio_uninit()
  * when IO has completed, or when the bio is released.
  */
-void bio_init(struct bio *bio, struct bio_vec *table,
-             unsigned short max_vecs)
+void bio_init(struct bio *bio, struct block_device *bdev, struct bio_vec *table,
+             unsigned short max_vecs, unsigned int opf)
 {
        bio->bi_next = NULL;
-       bio->bi_bdev = NULL;
-       bio->bi_opf = 0;
+       bio->bi_bdev = bdev;
+       bio->bi_opf = opf;
        bio->bi_flags = 0;
        bio->bi_ioprio = 0;
        bio->bi_write_hint = 0;
@@ -268,6 +268,8 @@ void bio_init(struct bio *bio, struct bio_vec *table,
 #ifdef CONFIG_BLK_CGROUP
        bio->bi_blkg = NULL;
        bio->bi_issue.value = 0;
+       if (bdev)
+               bio_associate_blkg(bio);
 #ifdef CONFIG_BLK_CGROUP_IOCOST
        bio->bi_iocost_cost = 0;
 #endif
@@ -504,17 +506,14 @@ struct bio *bio_alloc_bioset(struct block_device *bdev, unsigned short nr_vecs,
                if (unlikely(!bvl))
                        goto err_free;
 
-               bio_init(bio, bvl, nr_vecs);
+               bio_init(bio, bdev, bvl, nr_vecs, opf);
        } else if (nr_vecs) {
-               bio_init(bio, bio->bi_inline_vecs, BIO_INLINE_VECS);
+               bio_init(bio, bdev, bio->bi_inline_vecs, BIO_INLINE_VECS, opf);
        } else {
-               bio_init(bio, NULL, 0);
+               bio_init(bio, bdev, NULL, 0, opf);
        }
 
        bio->bi_pool = bs;
-       if (bdev)
-               bio_set_dev(bio, bdev);
-       bio->bi_opf = opf;
        return bio;
 
 err_free:
@@ -542,7 +541,8 @@ struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned short nr_iovecs)
        bio = kmalloc(struct_size(bio, bi_inline_vecs, nr_iovecs), gfp_mask);
        if (unlikely(!bio))
                return NULL;
-       bio_init(bio, nr_iovecs ? bio->bi_inline_vecs : NULL, nr_iovecs);
+       bio_init(bio, NULL, nr_iovecs ? bio->bi_inline_vecs : NULL, nr_iovecs,
+                0);
        bio->bi_pool = NULL;
        return bio;
 }
@@ -1756,9 +1756,8 @@ struct bio *bio_alloc_kiocb(struct kiocb *kiocb, struct block_device *bdev,
                cache->free_list = bio->bi_next;
                cache->nr--;
                put_cpu();
-               bio_init(bio, nr_vecs ? bio->bi_inline_vecs : NULL, nr_vecs);
-               bio_set_dev(bio, bdev);
-               bio->bi_opf = opf;
+               bio_init(bio, bdev, nr_vecs ? bio->bi_inline_vecs : NULL,
+                        nr_vecs, opf);
                bio->bi_pool = bs;
                bio_set_flag(bio, BIO_PERCPU_CACHE);
                return bio;
index e4df894189cedbaa98c121dc050bb85ff2dd20df..c689687248706ab40f32fc229b7985fb5b21a1a5 100644 (file)
@@ -460,9 +460,7 @@ int blkdev_issue_flush(struct block_device *bdev)
 {
        struct bio bio;
 
-       bio_init(&bio, NULL, 0);
-       bio_set_dev(&bio, bdev);
-       bio.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
+       bio_init(&bio, bdev, NULL, 0, REQ_OP_WRITE | REQ_PREFLUSH);
        return submit_bio_wait(&bio);
 }
 EXPORT_SYMBOL(blkdev_issue_flush);
index 5ab755d792c81f4c554699b042d81f3bf1f3a76f..602bef54c813499d1f3de1ad812c2220d8abadb5 100644 (file)
@@ -238,10 +238,7 @@ static int blkdev_zone_reset_all(struct block_device *bdev, gfp_t gfp_mask)
 {
        struct bio bio;
 
-       bio_init(&bio, NULL, 0);
-       bio_set_dev(&bio, bdev);
-       bio.bi_opf = REQ_OP_ZONE_RESET_ALL | REQ_SYNC;
-
+       bio_init(&bio, bdev, NULL, 0, REQ_OP_ZONE_RESET_ALL | REQ_SYNC);
        return submit_bio_wait(&bio);
 }
 
index c6835968477315ffddf6a442656ccd8c6311f37f..3696665e586a82bc3ac56afaff1d4246e5202cae 100644 (file)
@@ -75,8 +75,13 @@ static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb,
                        return -ENOMEM;
        }
 
-       bio_init(&bio, vecs, nr_pages);
-       bio_set_dev(&bio, bdev);
+       if (iov_iter_rw(iter) == READ) {
+               bio_init(&bio, bdev, vecs, nr_pages, REQ_OP_READ);
+               if (iter_is_iovec(iter))
+                       should_dirty = true;
+       } else {
+               bio_init(&bio, bdev, vecs, nr_pages, dio_bio_write_op(iocb));
+       }
        bio.bi_iter.bi_sector = pos >> SECTOR_SHIFT;
        bio.bi_write_hint = iocb->ki_hint;
        bio.bi_private = current;
@@ -88,14 +93,9 @@ static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb,
                goto out;
        ret = bio.bi_iter.bi_size;
 
-       if (iov_iter_rw(iter) == READ) {
-               bio.bi_opf = REQ_OP_READ;
-               if (iter_is_iovec(iter))
-                       should_dirty = true;
-       } else {
-               bio.bi_opf = dio_bio_write_op(iocb);
+       if (iov_iter_rw(iter) == WRITE)
                task_io_account_write(ret);
-       }
+
        if (iocb->ki_flags & IOCB_NOWAIT)
                bio.bi_opf |= REQ_NOWAIT;
        if (iocb->ki_flags & IOCB_HIPRI)
index e611411a934ce793282112be7293da500c9f98e3..19c2d0327e157ae2ac79b57933018fa301f5d022 100644 (file)
@@ -4129,15 +4129,13 @@ static int __floppy_read_block_0(struct block_device *bdev, int drive)
 
        cbdata.drive = drive;
 
-       bio_init(&bio, &bio_vec, 1);
-       bio_set_dev(&bio, bdev);
+       bio_init(&bio, bdev, &bio_vec, 1, REQ_OP_READ);
        bio_add_page(&bio, page, block_size(bdev), 0);
 
        bio.bi_iter.bi_sector = 0;
        bio.bi_flags |= (1 << BIO_QUIET);
        bio.bi_private = &cbdata;
        bio.bi_end_io = floppy_rb0_cb;
-       bio_set_op_attrs(&bio, REQ_OP_READ, 0);
 
        init_completion(&cbdata.complete);
 
index f3fe0ea8aa80fc170ff489506d93e5759c78b58b..a3a5e1e7132682b2ca68bc01af64694c17262274 100644 (file)
@@ -743,10 +743,9 @@ static ssize_t writeback_store(struct device *dev,
                        continue;
                }
 
-               bio_init(&bio, &bio_vec, 1);
-               bio_set_dev(&bio, zram->bdev);
+               bio_init(&bio, zram->bdev, &bio_vec, 1,
+                        REQ_OP_WRITE | REQ_SYNC);
                bio.bi_iter.bi_sector = blk_idx * (PAGE_SIZE >> 9);
-               bio.bi_opf = REQ_OP_WRITE | REQ_SYNC;
 
                bio_add_page(&bio, bvec.bv_page, bvec.bv_len,
                                bvec.bv_offset);
index 9c6f9ec55b724d1efcbc51f93a17df058d51361d..020712c5203fdd9fa963221d78e30e012536c012 100644 (file)
@@ -26,7 +26,8 @@ struct bio *bch_bbio_alloc(struct cache_set *c)
        struct bbio *b = mempool_alloc(&c->bio_meta, GFP_NOIO);
        struct bio *bio = &b->bio;
 
-       bio_init(bio, bio->bi_inline_vecs, meta_bucket_pages(&c->cache->sb));
+       bio_init(bio, NULL, bio->bi_inline_vecs,
+                meta_bucket_pages(&c->cache->sb), 0);
 
        return bio;
 }
index 61bd79babf7ae50b41e14f0fc2ac36e5baa645d1..6d26c5b06e2b66ccc77413b3ce2583c33ada6da1 100644 (file)
@@ -611,11 +611,9 @@ static void do_journal_discard(struct cache *ca)
 
                atomic_set(&ja->discard_in_flight, DISCARD_IN_FLIGHT);
 
-               bio_init(bio, bio->bi_inline_vecs, 1);
-               bio_set_op_attrs(bio, REQ_OP_DISCARD, 0);
+               bio_init(bio, ca->bdev, bio->bi_inline_vecs, 1, REQ_OP_DISCARD);
                bio->bi_iter.bi_sector  = bucket_to_sector(ca->set,
                                                ca->sb.d[ja->discard_idx]);
-               bio_set_dev(bio, ca->bdev);
                bio->bi_iter.bi_size    = bucket_bytes(ca);
                bio->bi_end_io          = journal_discard_endio;
 
index b9c3d27ec093a1ba1ab30e6949bbbb8888625b49..99499d1f6e66664a4cc9d863d951bda1cc3ab788 100644 (file)
@@ -79,8 +79,8 @@ static void moving_init(struct moving_io *io)
 {
        struct bio *bio = &io->bio.bio;
 
-       bio_init(bio, bio->bi_inline_vecs,
-                DIV_ROUND_UP(KEY_SIZE(&io->w->key), PAGE_SECTORS));
+       bio_init(bio, NULL, bio->bi_inline_vecs,
+                DIV_ROUND_UP(KEY_SIZE(&io->w->key), PAGE_SECTORS), 0);
        bio_get(bio);
        bio_set_prio(bio, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0));
 
index c4b7e434de8ac125a9ae3026cc96f71e9025aa20..d4b98ebffd9485791ae49db28aaeddab59178286 100644 (file)
@@ -685,7 +685,7 @@ static void do_bio_hook(struct search *s,
 {
        struct bio *bio = &s->bio.bio;
 
-       bio_init(bio, NULL, 0);
+       bio_init(bio, NULL, NULL, 0, 0);
        __bio_clone_fast(bio, orig_bio);
        /*
         * bi_end_io can be set separately somewhere else, e.g. the
index c31a62b963f009c4e3b7662930d37779447e14f7..bf3de149d3c9f8ff6695877ffd786df24bb04ff5 100644 (file)
@@ -342,8 +342,7 @@ void bch_write_bdev_super(struct cached_dev *dc, struct closure *parent)
        down(&dc->sb_write_mutex);
        closure_init(cl, parent);
 
-       bio_init(bio, dc->sb_bv, 1);
-       bio_set_dev(bio, dc->bdev);
+       bio_init(bio, dc->bdev, dc->sb_bv, 1, 0);
        bio->bi_end_io  = write_bdev_super_endio;
        bio->bi_private = dc;
 
@@ -386,8 +385,7 @@ void bcache_write_super(struct cache_set *c)
        if (ca->sb.version < version)
                ca->sb.version = version;
 
-       bio_init(bio, ca->sb_bv, 1);
-       bio_set_dev(bio, ca->bdev);
+       bio_init(bio, ca->bdev, ca->sb_bv, 1, 0);
        bio->bi_end_io  = write_super_endio;
        bio->bi_private = ca;
 
@@ -2239,7 +2237,7 @@ static int cache_alloc(struct cache *ca)
        __module_get(THIS_MODULE);
        kobject_init(&ca->kobj, &bch_cache_ktype);
 
-       bio_init(&ca->journal.bio, ca->journal.bio.bi_inline_vecs, 8);
+       bio_init(&ca->journal.bio, NULL, ca->journal.bio.bi_inline_vecs, 8, 0);
 
        /*
         * when ca->sb.njournal_buckets is not zero, journal exists,
index c7560f66dca88ad4c2f9582cdbc7b674ae44a9fb..d42301e6309d4b287863aff7b9cab0e441618d27 100644 (file)
@@ -292,8 +292,8 @@ static void dirty_init(struct keybuf_key *w)
        struct dirty_io *io = w->private;
        struct bio *bio = &io->bio;
 
-       bio_init(bio, bio->bi_inline_vecs,
-                DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS));
+       bio_init(bio, NULL, bio->bi_inline_vecs,
+                DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS), 0);
        if (!io->dc->writeback_percent)
                bio_set_prio(bio, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0));
 
index 069e29013b6be1ef679da40721003276dc6c50a4..fa596b654c99c170141d8b25fea5e1fad2a696c0 100644 (file)
@@ -1303,9 +1303,8 @@ static int __send_empty_flush(struct clone_info *ci)
         * need to reference it after submit. It's just used as
         * the basis for the clone(s).
         */
-       bio_init(&flush_bio, NULL, 0);
-       flush_bio.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC;
-       bio_set_dev(&flush_bio, ci->io->md->disk->part0);
+       bio_init(&flush_bio, ci->io->md->disk->part0, NULL, 0,
+                REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC);
 
        ci->bio = &flush_bio;
        ci->sector_count = 0;
index e7d6486f090ff903a2de461d55879d8b35761c6f..5e15940634d8597f2aa57c81ff2d88a0924107cf 100644 (file)
@@ -121,7 +121,7 @@ static bool multipath_make_request(struct mddev *mddev, struct bio * bio)
        }
        multipath = conf->multipaths + mp_bh->path;
 
-       bio_init(&mp_bh->bio, NULL, 0);
+       bio_init(&mp_bh->bio, NULL, NULL, 0, 0);
        __bio_clone_fast(&mp_bh->bio, bio);
 
        mp_bh->bio.bi_iter.bi_sector += multipath->rdev->data_offset;
index 40fc1f7e65c5d93e5243648db841e044887c73dd..0a89f072dae0d04d936c7ba3b71965249be947cc 100644 (file)
@@ -998,13 +998,11 @@ int sync_page_io(struct md_rdev *rdev, sector_t sector, int size,
        struct bio bio;
        struct bio_vec bvec;
 
-       bio_init(&bio, &bvec, 1);
-
        if (metadata_op && rdev->meta_bdev)
-               bio_set_dev(&bio, rdev->meta_bdev);
+               bio_init(&bio, rdev->meta_bdev, &bvec, 1, op | op_flags);
        else
-               bio_set_dev(&bio, rdev->bdev);
-       bio.bi_opf = op | op_flags;
+               bio_init(&bio, rdev->bdev, &bvec, 1, op | op_flags);
+
        if (metadata_op)
                bio.bi_iter.bi_sector = sector + rdev->sb_start;
        else if (rdev->mddev->reshape_position != MaxSector &&
index 66313adf99875dc0fad052274b29f1c7f12bf024..98b9ca11c28d8170066153c3b8ed1a6542ae85e5 100644 (file)
@@ -3108,7 +3108,7 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)
        INIT_LIST_HEAD(&log->io_end_ios);
        INIT_LIST_HEAD(&log->flushing_ios);
        INIT_LIST_HEAD(&log->finished_ios);
-       bio_init(&log->flush_bio, NULL, 0);
+       bio_init(&log->flush_bio, NULL, NULL, 0, 0);
 
        log->io_kc = KMEM_CACHE(r5l_io_unit, 0);
        if (!log->io_kc)
index 054d3bb252d48da98dea39bfa85d3b56ba9c7eba..3446797fa0acae2584992c2b475a32a075f5ae46 100644 (file)
@@ -250,7 +250,7 @@ static struct ppl_io_unit *ppl_new_iounit(struct ppl_log *log,
        INIT_LIST_HEAD(&io->stripe_list);
        atomic_set(&io->pending_stripes, 0);
        atomic_set(&io->pending_flushes, 0);
-       bio_init(&io->bio, io->biovec, PPL_IO_INLINE_BVECS);
+       bio_init(&io->bio, NULL, io->biovec, PPL_IO_INLINE_BVECS, 0);
 
        pplhdr = page_address(io->header_page);
        clear_page(pplhdr);
index ffe720c73b0a543aeacafec29113b7c412e747cc..a9dcc5bc9c329e6eb85266db1239871b121e34a1 100644 (file)
@@ -2310,8 +2310,8 @@ static struct stripe_head *alloc_stripe(struct kmem_cache *sc, gfp_t gfp,
                for (i = 0; i < disks; i++) {
                        struct r5dev *dev = &sh->dev[i];
 
-                       bio_init(&dev->req, &dev->vec, 1);
-                       bio_init(&dev->rreq, &dev->rvec, 1);
+                       bio_init(&dev->req, NULL, &dev->vec, 1, 0);
+                       bio_init(&dev->rreq, NULL, &dev->rvec, 1, 0);
                }
 
                if (raid5_has_ppl(conf)) {
index e092af3abc710ae2fdf9b0a74f510f83846198ca..95c2bbb0b2f5f2ada18897e891a39cf14fc8defc 100644 (file)
@@ -267,9 +267,8 @@ static void nvmet_bdev_execute_rw(struct nvmet_req *req)
 
        if (nvmet_use_inline_bvec(req)) {
                bio = &req->b.inline_bio;
-               bio_init(bio, req->inline_bvec, ARRAY_SIZE(req->inline_bvec));
-               bio_set_dev(bio, req->ns->bdev);
-               bio->bi_opf = op;
+               bio_init(bio, req->ns->bdev, req->inline_bvec,
+                        ARRAY_SIZE(req->inline_bvec), op);
        } else {
                bio = bio_alloc(req->ns->bdev, bio_max_segs(sg_cnt), op,
                                GFP_KERNEL);
@@ -328,11 +327,10 @@ static void nvmet_bdev_execute_flush(struct nvmet_req *req)
        if (!nvmet_check_transfer_len(req, 0))
                return;
 
-       bio_init(bio, req->inline_bvec, ARRAY_SIZE(req->inline_bvec));
-       bio_set_dev(bio, req->ns->bdev);
+       bio_init(bio, req->ns->bdev, req->inline_bvec,
+                ARRAY_SIZE(req->inline_bvec), REQ_OP_WRITE | REQ_PREFLUSH);
        bio->bi_private = req;
        bio->bi_end_io = nvmet_bio_done;
-       bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
 
        submit_bio(bio);
 }
index 38f72968c3fdeb53dc3212eb2a12421d5d624497..a810bf569fff87752f9bdb9de344d905911bde9d 100644 (file)
@@ -206,8 +206,8 @@ static int nvmet_passthru_map_sg(struct nvmet_req *req, struct request *rq)
 
        if (nvmet_use_inline_bvec(req)) {
                bio = &req->p.inline_bio;
-               bio_init(bio, req->inline_bvec, ARRAY_SIZE(req->inline_bvec));
-               bio->bi_opf = req_op(rq);
+               bio_init(bio, NULL, req->inline_bvec,
+                        ARRAY_SIZE(req->inline_bvec), req_op(rq));
        } else {
                bio = bio_alloc(NULL, bio_max_segs(req->sg_cnt), req_op(rq),
                                GFP_KERNEL);
index 62c53e8f26d35c3936d9c6934b032cc5ec566ba3..3e421217a7adec85eebd6a5a8625df5dc64e3b60 100644 (file)
@@ -552,8 +552,8 @@ void nvmet_bdev_execute_zone_append(struct nvmet_req *req)
 
        if (nvmet_use_inline_bvec(req)) {
                bio = &req->z.inline_bio;
-               bio_init(bio, req->inline_bvec, ARRAY_SIZE(req->inline_bvec));
-               bio->bi_opf = op;
+               bio_init(bio, req->ns->bdev, req->inline_bvec,
+                        ARRAY_SIZE(req->inline_bvec), op);
        } else {
                bio = bio_alloc(req->ns->bdev, req->sg_cnt, op, GFP_KERNEL);
        }
index 70f3657a6ec064dc7990580f8fa1a3dc70afc935..491534e9086155f2b50accad4fda03aa60a895a9 100644 (file)
@@ -549,10 +549,8 @@ static int iomap_read_folio_sync(loff_t block_start, struct folio *folio,
        struct bio_vec bvec;
        struct bio bio;
 
-       bio_init(&bio, &bvec, 1);
-       bio.bi_opf = REQ_OP_READ;
+       bio_init(&bio, iomap->bdev, &bvec, 1, REQ_OP_READ);
        bio.bi_iter.bi_sector = iomap_sector(iomap, block_start);
-       bio_set_dev(&bio, iomap->bdev);
        bio_add_folio(&bio, folio, plen, poff);
        return submit_bio_wait(&bio);
 }
index eff4a9f21dcffb04326e6e8e7360e9e48d0b86d6..32fa02945f7399d30b367dac248bf4fb344582c6 100644 (file)
@@ -36,9 +36,7 @@ xfs_flush_bdev_async(
                return;
        }
 
-       bio_init(bio, NULL, 0);
-       bio_set_dev(bio, bdev);
-       bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC;
+       bio_init(bio, bdev, NULL, 0, REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC);
        bio->bi_private = done;
        bio->bi_end_io = xfs_flush_bdev_async_endio;
 
index 89fec9a18c34953333718f0a2e924a39f3214f48..16f9edbda4eb3ddd02b97b1e8ecc62f0697569c7 100644 (file)
@@ -1883,19 +1883,19 @@ xlog_write_iclog(
                return;
        }
 
-       bio_init(&iclog->ic_bio, iclog->ic_bvec, howmany(count, PAGE_SIZE));
-       bio_set_dev(&iclog->ic_bio, log->l_targ->bt_bdev);
-       iclog->ic_bio.bi_iter.bi_sector = log->l_logBBstart + bno;
-       iclog->ic_bio.bi_end_io = xlog_bio_end_io;
-       iclog->ic_bio.bi_private = iclog;
-
        /*
         * We use REQ_SYNC | REQ_IDLE here to tell the block layer the are more
         * IOs coming immediately after this one. This prevents the block layer
         * writeback throttle from throttling log writes behind background
         * metadata writeback and causing priority inversions.
         */
-       iclog->ic_bio.bi_opf = REQ_OP_WRITE | REQ_META | REQ_SYNC | REQ_IDLE;
+       bio_init(&iclog->ic_bio, log->l_targ->bt_bdev, iclog->ic_bvec,
+                howmany(count, PAGE_SIZE),
+                REQ_OP_WRITE | REQ_META | REQ_SYNC | REQ_IDLE);
+       iclog->ic_bio.bi_iter.bi_sector = log->l_logBBstart + bno;
+       iclog->ic_bio.bi_end_io = xlog_bio_end_io;
+       iclog->ic_bio.bi_private = iclog;
+
        if (iclog->ic_flags & XLOG_ICL_NEED_FLUSH) {
                iclog->ic_bio.bi_opf |= REQ_PREFLUSH;
                /*
index c0fc2c326dcee87a85ec9c45ba6765c701cfe071..d331b52592a0a4dc6d9f2f54abe2e915ef02392b 100644 (file)
@@ -1540,10 +1540,8 @@ static int zonefs_read_super(struct super_block *sb)
        if (!page)
                return -ENOMEM;
 
-       bio_init(&bio, &bio_vec, 1);
+       bio_init(&bio, sb->s_bdev, &bio_vec, 1, REQ_OP_READ);
        bio.bi_iter.bi_sector = 0;
-       bio.bi_opf = REQ_OP_READ;
-       bio_set_dev(&bio, sb->s_bdev);
        bio_add_page(&bio, page, PAGE_SIZE, 0);
 
        ret = submit_bio_wait(&bio);
index be6ac92913d48e9ee185f6301835da712a4c5e6c..41bedf727f59c97f83b6924c1e06673820e471d5 100644 (file)
@@ -456,8 +456,8 @@ static inline int bio_iov_vecs_to_alloc(struct iov_iter *iter, int max_segs)
 struct request_queue;
 
 extern int submit_bio_wait(struct bio *bio);
-extern void bio_init(struct bio *bio, struct bio_vec *table,
-                    unsigned short max_vecs);
+void bio_init(struct bio *bio, struct block_device *bdev, struct bio_vec *table,
+             unsigned short max_vecs, unsigned int opf);
 extern void bio_uninit(struct bio *);
 extern void bio_reset(struct bio *);
 void bio_chain(struct bio *, struct bio *);