linux-bcache.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* additional ->bi_bdev fixups
@ 2021-01-26 14:33 Christoph Hellwig
  2021-01-26 14:33 ` [PATCH 1/3] nvme: use bio_set_dev to assign ->bi_bdev Christoph Hellwig
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Christoph Hellwig @ 2021-01-26 14:33 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-nvme, linux-bcache

Hi Jens,

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] nvme: use bio_set_dev to assign ->bi_bdev
  2021-01-26 14:33 additional ->bi_bdev fixups Christoph Hellwig
@ 2021-01-26 14:33 ` Christoph Hellwig
  2021-01-26 14:33 ` [PATCH 2/3] bcache: " Christoph Hellwig
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2021-01-26 14:33 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-nvme, linux-bcache

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] bcache: use bio_set_dev to assign ->bi_bdev
  2021-01-26 14:33 additional ->bi_bdev fixups Christoph Hellwig
  2021-01-26 14:33 ` [PATCH 1/3] nvme: use bio_set_dev to assign ->bi_bdev Christoph Hellwig
@ 2021-01-26 14:33 ` Christoph Hellwig
  2021-01-27 13:12   ` Coly Li
  2021-01-26 14:33 ` [PATCH 3/3] block: inherit BIO_REMAPPED when cloning bios Christoph Hellwig
  2021-01-26 15:50 ` additional ->bi_bdev fixups Jens Axboe
  3 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2021-01-26 14:33 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-nvme, linux-bcache

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] block: inherit BIO_REMAPPED when cloning bios
  2021-01-26 14:33 additional ->bi_bdev fixups Christoph Hellwig
  2021-01-26 14:33 ` [PATCH 1/3] nvme: use bio_set_dev to assign ->bi_bdev Christoph Hellwig
  2021-01-26 14:33 ` [PATCH 2/3] bcache: " Christoph Hellwig
@ 2021-01-26 14:33 ` Christoph Hellwig
  2021-01-26 15:50 ` additional ->bi_bdev fixups Jens Axboe
  3 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2021-01-26 14:33 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-nvme, linux-bcache

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: additional ->bi_bdev fixups
  2021-01-26 14:33 additional ->bi_bdev fixups Christoph Hellwig
                   ` (2 preceding siblings ...)
  2021-01-26 14:33 ` [PATCH 3/3] block: inherit BIO_REMAPPED when cloning bios Christoph Hellwig
@ 2021-01-26 15:50 ` Jens Axboe
  3 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2021-01-26 15:50 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-block, linux-nvme, linux-bcache

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] bcache: use bio_set_dev to assign ->bi_bdev
  2021-01-26 14:33 ` [PATCH 2/3] bcache: " Christoph Hellwig
@ 2021-01-27 13:12   ` Coly Li
  0 siblings, 0 replies; 6+ messages in thread
From: Coly Li @ 2021-01-27 13:12 UTC (permalink / raw)
  To: Christoph Hellwig, axboe; +Cc: linux-block, linux-nvme, linux-bcache

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 <colyli@suse.de>


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;
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-27 13:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-26 14:33 additional ->bi_bdev fixups Christoph Hellwig
2021-01-26 14:33 ` [PATCH 1/3] nvme: use bio_set_dev to assign ->bi_bdev Christoph Hellwig
2021-01-26 14:33 ` [PATCH 2/3] bcache: " Christoph Hellwig
2021-01-27 13:12   ` Coly Li
2021-01-26 14:33 ` [PATCH 3/3] block: inherit BIO_REMAPPED when cloning bios Christoph Hellwig
2021-01-26 15:50 ` additional ->bi_bdev fixups Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).