additional ->bi_bdev fixups
From: Christoph Hellwig <hch@lst.de>
Date: 2021-01-26 14:36:08
Hi Jens, more fixes for the (so far theoretical) fallout from the ->bi_bdev conversion.
6 messages, 3 authors, 2021-01-27 · open the first message on its own page
From: Christoph Hellwig <hch@lst.de>
Date: 2021-01-26 14:36:08
Hi Jens, more fixes for the (so far theoretical) fallout from the ->bi_bdev conversion.
From: Christoph Hellwig <hch@lst.de>
Date: 2021-01-26 14:37:31
Always use the bio_set_dev helper to assign ->bi_bdev to make sure other state related to the device is uptodate. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/nvme/host/core.c | 2 +- drivers/nvme/host/lightnvm.c | 2 +- drivers/nvme/host/multipath.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index eb7963fb167b56..ba5df80881ea98 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c@@ -1133,7 +1133,7 @@ static int nvme_submit_user_cmd(struct request_queue *q, if (ret) goto out; bio = req->bio; - bio->bi_bdev = bdev; + bio_set_dev(bio, bdev); if (bdev && meta_buffer && meta_len) { meta = nvme_add_user_metadata(bio, meta_buffer, meta_len, meta_seed, write);
diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
index ec38128f51e994..b705988629f224 100644
--- a/drivers/nvme/host/lightnvm.c
+++ b/drivers/nvme/host/lightnvm.c@@ -816,7 +816,7 @@ static int nvme_nvm_submit_user_cmd(struct request_queue *q, vcmd->ph_rw.metadata = cpu_to_le64(metadata_dma); } - bio->bi_bdev = ns->disk->part0; + bio_set_dev(bio, ns->disk->part0); } blk_execute_rq(NULL, rq, 0);
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index a6d44e7a775f54..65bd6efa5e1c69 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c@@ -312,7 +312,7 @@ blk_qc_t nvme_ns_head_submit_bio(struct bio *bio) srcu_idx = srcu_read_lock(&head->srcu); ns = nvme_find_path(head); if (likely(ns)) { - bio->bi_bdev = ns->disk->part0; + bio_set_dev(bio, ns->disk->part0); bio->bi_opf |= REQ_NVME_MPATH; trace_block_bio_remap(bio, disk_devt(ns->head->disk), bio->bi_iter.bi_sector);
@@ -352,7 +352,7 @@ static void nvme_requeue_work(struct work_struct *work) * Reset disk to the mpath node and resubmit to select a new * path. */ - bio->bi_bdev = head->disk->part0; + bio_set_dev(bio, head->disk->part0); submit_bio_noacct(bio); } }
--
2.29.2
From: Christoph Hellwig <hch@lst.de>
Date: 2021-01-26 14:38:36
Always use the bio_set_dev helper to assign ->bi_bdev to make sure other state related to the device is uptodate. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/md/bcache/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index 058dd80144281e..63e809f38e3f51 100644
--- a/drivers/md/bcache/debug.c
+++ b/drivers/md/bcache/debug.c@@ -114,7 +114,7 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) check = bio_kmalloc(GFP_NOIO, bio_segments(bio)); if (!check) return; - check->bi_bdev = bio->bi_bdev; + bio_set_dev(check, bio->bi_bdev); check->bi_opf = REQ_OP_READ; check->bi_iter.bi_sector = bio->bi_iter.bi_sector; check->bi_iter.bi_size = bio->bi_iter.bi_size;
--
2.29.2
From: Christoph Hellwig <hch@lst.de>
Date: 2021-01-26 14:39:22
Cloned bios are can be used to on the same device, in which case we need
to inherit the BIO_REMAPPED flag to avoid a double partition remap. When
the cloned bios are used on another device, bio_set_dev will clear the flag.
Fixes: 309dca309fc3 ("block: store a block_device pointer in struct bio")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/bio.c | 2 ++
block/blk-crypto-fallback.c | 2 ++
block/bounce.c | 2 ++
3 files changed, 6 insertions(+)
diff --git a/block/bio.c b/block/bio.c
index 99040a7e6656a1..dfd7740a32300a 100644
--- a/block/bio.c
+++ b/block/bio.c@@ -666,6 +666,8 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src) bio_set_flag(bio, BIO_CLONED); if (bio_flagged(bio_src, BIO_THROTTLED)) bio_set_flag(bio, BIO_THROTTLED); + if (bio_flagged(bio_src, BIO_REMAPPED)) + bio_set_flag(bio, BIO_REMAPPED); bio->bi_opf = bio_src->bi_opf; bio->bi_ioprio = bio_src->bi_ioprio; bio->bi_write_hint = bio_src->bi_write_hint;
diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c
index 8f1e1817673115..50c225398e4d60 100644
--- a/block/blk-crypto-fallback.c
+++ b/block/blk-crypto-fallback.c@@ -168,6 +168,8 @@ static struct bio *blk_crypto_clone_bio(struct bio *bio_src) if (!bio) return NULL; bio->bi_bdev = bio_src->bi_bdev; + if (bio_flagged(bio_src, BIO_REMAPPED)) + bio_set_flag(bio, BIO_REMAPPED); bio->bi_opf = bio_src->bi_opf; bio->bi_ioprio = bio_src->bi_ioprio; bio->bi_write_hint = bio_src->bi_write_hint;
diff --git a/block/bounce.c b/block/bounce.c
index a22a8a1942b24f..fc55314aa4269a 100644
--- a/block/bounce.c
+++ b/block/bounce.c@@ -247,6 +247,8 @@ static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask, if (!bio) return NULL; bio->bi_bdev = bio_src->bi_bdev; + if (bio_flagged(bio_src, BIO_REMAPPED)) + bio_set_flag(bio, BIO_REMAPPED); bio->bi_opf = bio_src->bi_opf; bio->bi_ioprio = bio_src->bi_ioprio; bio->bi_write_hint = bio_src->bi_write_hint;
--
2.29.2
From: Jens Axboe <axboe@kernel.dk>
Date: 2021-01-26 15:52:16
On 1/26/21 7:33 AM, Christoph Hellwig wrote:
Hi Jens, more fixes for the (so far theoretical) fallout from the ->bi_bdev conversion.
Applied, thanks. -- Jens Axboe
From: Coly Li <hidden>
Date: 2021-01-27 13:15:10
On 1/26/21 10:33 PM, Christoph Hellwig wrote:
Always use the bio_set_dev helper to assign ->bi_bdev to make sure other state related to the device is uptodate. Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Coly Li <redacted> Coly Li
--- drivers/md/bcache/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 058dd80144281e..63e809f38e3f51 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c@@ -114,7 +114,7 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) check = bio_kmalloc(GFP_NOIO, bio_segments(bio)); if (!check) return; - check->bi_bdev = bio->bi_bdev; + bio_set_dev(check, bio->bi_bdev); check->bi_opf = REQ_OP_READ; check->bi_iter.bi_sector = bio->bi_iter.bi_sector; check->bi_iter.bi_size = bio->bi_iter.bi_size;