Skip to contentSkip to conversation

additional ->bi_bdev fixups

PATCH In review Christoph Hellwig 3 participants 6 messages Jan 26, 2021 – Jan 27, 2021

Subsystems (3)
lore
Share & tools
lore
author maintainer
#1 lore raw

PATCH 1/3 nvme: use bio_set_dev to assign ->bi_bdev

Always use the bio_set_dev helper to assign ->bi_bdev to make sure other state related to the device is uptodate.

---
 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(-)
drivers/nvme/host/core.c +1 -1
index eb7963fb167b56..ba5df80881ea98 100644
@@ -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);
drivers/nvme/host/lightnvm.c +1 -1
index ec38128f51e994..b705988629f224 100644
@@ -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);
drivers/nvme/host/multipath.c +2 -2
index a6d44e7a775f54..65bd6efa5e1c69 100644
@@ -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);
 	}
 }
Signature · 7 lines
2.29.2


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
author maintainer
#2 lore raw

PATCH 2/3 bcache: use bio_set_dev to assign ->bi_bdev

In reply to Christoph Hellwig

Always use the bio_set_dev helper to assign ->bi_bdev to make sure other state related to the device is uptodate.

---
 drivers/md/bcache/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/debug.c +1 -1
index 058dd80144281e..63e809f38e3f51 100644
@@ -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;
Signature · 7 lines
2.29.2


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Acked-by on v1 2/3
#3 lore raw

Re: [PATCH 2/3] bcache: use bio_set_dev to assign ->bi_bdev

Quoted 4 lines · Christoph Hellwig

Always use the bio_set_dev helper to assign ->bi_bdev to make sure other state related to the device is uptodate.

Coly Li

Quoted 10 lines
---
 drivers/md/bcache/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/debug.c +0 -0
index 058dd80144281e..63e809f38e3f51 100644

drivers/md/bcache/debug.c void bch_data_verify(struct cached_dev *dc, struct bio *bio) · line 120

Quoted 8 lines
drivers/md/bcache/debug.c +1 -1
@@ -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;

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

author maintainer
#4 lore raw

PATCH 3/3 block: inherit BIO_REMAPPED when cloning bios

In reply to Christoph Hellwig

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")
---
 block/bio.c                 | 2 ++
 block/blk-crypto-fallback.c | 2 ++
 block/bounce.c              | 2 ++
 3 files changed, 6 insertions(+)
block/bio.c +2 -0
index 99040a7e6656a1..dfd7740a32300a 100644
@@ -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;
block/blk-crypto-fallback.c +2 -0
index 8f1e1817673115..50c225398e4d60 100644
@@ -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;
block/bounce.c +2 -0
index a22a8a1942b24f..fc55314aa4269a 100644
@@ -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;
Signature · 7 lines
2.29.2


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
maintainer Applied
#5 lore raw
In reply to Christoph Hellwig
Quoted 4 lines · Christoph Hellwig

Hi Jens,

more fixes for the (so far theoretical) fallout from the ->bi_bdev conversion.

Applied, thanks.

Signature · 7 lines
Jens Axboe


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme