All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Tejun Heo <tj@kernel.org>, Coly Li <colyli@suse.de>,
	Song Liu <song@kernel.org>,
	dm-devel@redhat.com, linux-bcache@vger.kernel.org,
	linux-raid@vger.kernel.org, linux-s390@vger.kernel.org,
	linux-block@vger.kernel.org
Subject: [PATCH 05/10] block: do not reassig ->bi_bdev when partition remapping
Date: Sun, 24 Jan 2021 11:02:36 +0100	[thread overview]
Message-ID: <20210124100241.1167849-6-hch@lst.de> (raw)
In-Reply-To: <20210124100241.1167849-1-hch@lst.de>

There is no good reason to reassign ->bi_bdev when remapping the
partition-relative block number to the device wide one, as all the
information required by the drivers comes from the gendisk anyway.

Keeping the original ->bi_bdev alive will allow to greatly simplify
the partition-away I/O accounting.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Tejun Heo <tj@kernel.org>
---
 block/blk-core.c          | 5 +++--
 include/linux/bio.h       | 2 ++
 include/linux/blk_types.h | 1 +
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 64f69022de9627..1c1b97a82caa2e 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -752,7 +752,7 @@ static int blk_partition_remap(struct bio *bio)
 				      bio->bi_iter.bi_sector -
 				      p->bd_start_sect);
 	}
-	bio->bi_bdev = bdev_whole(p);
+	bio_set_flag(bio, BIO_REMAPPED);
 	return 0;
 }
 
@@ -817,7 +817,8 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio)
 		goto end_io;
 	if (unlikely(bio_check_eod(bio)))
 		goto end_io;
-	if (bio->bi_bdev->bd_partno && unlikely(blk_partition_remap(bio)))
+	if (bio->bi_bdev->bd_partno && !bio_flagged(bio, BIO_REMAPPED) &&
+	    unlikely(blk_partition_remap(bio)))
 		goto end_io;
 
 	/*
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 12af7aa5db3778..2f1155eabaff29 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -485,6 +485,7 @@ extern const char *bio_devname(struct bio *bio, char *buffer);
 
 #define bio_set_dev(bio, bdev) 				\
 do {							\
+	bio_clear_flag(bio, BIO_REMAPPED);		\
 	if ((bio)->bi_bdev != (bdev))			\
 		bio_clear_flag(bio, BIO_THROTTLED);	\
 	(bio)->bi_bdev = (bdev);			\
@@ -493,6 +494,7 @@ do {							\
 
 #define bio_copy_dev(dst, src)			\
 do {						\
+	bio_clear_flag(dst, BIO_REMAPPED);		\
 	(dst)->bi_bdev = (src)->bi_bdev;	\
 	bio_clone_blkg_association(dst, src);	\
 } while (0)
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 8ebd8be3e05082..1bc6f6a01070fc 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -303,6 +303,7 @@ enum {
 				 * of this bio. */
 	BIO_CGROUP_ACCT,	/* has been accounted to a cgroup */
 	BIO_TRACKED,		/* set if bio goes through the rq_qos path */
+	BIO_REMAPPED,
 	BIO_FLAG_LAST
 };
 
-- 
2.29.2


WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-s390@vger.kernel.org, linux-bcache@vger.kernel.org,
	Coly Li <colyli@suse.de>,
	linux-raid@vger.kernel.org, Song Liu <song@kernel.org>,
	dm-devel@redhat.com, linux-block@vger.kernel.org,
	Tejun Heo <tj@kernel.org>
Subject: [dm-devel] [PATCH 05/10] block: do not reassig ->bi_bdev when partition remapping
Date: Sun, 24 Jan 2021 11:02:36 +0100	[thread overview]
Message-ID: <20210124100241.1167849-6-hch@lst.de> (raw)
In-Reply-To: <20210124100241.1167849-1-hch@lst.de>

There is no good reason to reassign ->bi_bdev when remapping the
partition-relative block number to the device wide one, as all the
information required by the drivers comes from the gendisk anyway.

Keeping the original ->bi_bdev alive will allow to greatly simplify
the partition-away I/O accounting.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Tejun Heo <tj@kernel.org>
---
 block/blk-core.c          | 5 +++--
 include/linux/bio.h       | 2 ++
 include/linux/blk_types.h | 1 +
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 64f69022de9627..1c1b97a82caa2e 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -752,7 +752,7 @@ static int blk_partition_remap(struct bio *bio)
 				      bio->bi_iter.bi_sector -
 				      p->bd_start_sect);
 	}
-	bio->bi_bdev = bdev_whole(p);
+	bio_set_flag(bio, BIO_REMAPPED);
 	return 0;
 }
 
@@ -817,7 +817,8 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio)
 		goto end_io;
 	if (unlikely(bio_check_eod(bio)))
 		goto end_io;
-	if (bio->bi_bdev->bd_partno && unlikely(blk_partition_remap(bio)))
+	if (bio->bi_bdev->bd_partno && !bio_flagged(bio, BIO_REMAPPED) &&
+	    unlikely(blk_partition_remap(bio)))
 		goto end_io;
 
 	/*
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 12af7aa5db3778..2f1155eabaff29 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -485,6 +485,7 @@ extern const char *bio_devname(struct bio *bio, char *buffer);
 
 #define bio_set_dev(bio, bdev) 				\
 do {							\
+	bio_clear_flag(bio, BIO_REMAPPED);		\
 	if ((bio)->bi_bdev != (bdev))			\
 		bio_clear_flag(bio, BIO_THROTTLED);	\
 	(bio)->bi_bdev = (bdev);			\
@@ -493,6 +494,7 @@ do {							\
 
 #define bio_copy_dev(dst, src)			\
 do {						\
+	bio_clear_flag(dst, BIO_REMAPPED);		\
 	(dst)->bi_bdev = (src)->bi_bdev;	\
 	bio_clone_blkg_association(dst, src);	\
 } while (0)
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 8ebd8be3e05082..1bc6f6a01070fc 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -303,6 +303,7 @@ enum {
 				 * of this bio. */
 	BIO_CGROUP_ACCT,	/* has been accounted to a cgroup */
 	BIO_TRACKED,		/* set if bio goes through the rq_qos path */
+	BIO_REMAPPED,
 	BIO_FLAG_LAST
 };
 
-- 
2.29.2

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


  parent reply	other threads:[~2021-01-24 10:07 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-24 10:02 store a pointer to the block_device in struct bio (again) v2 Christoph Hellwig
2021-01-24 10:02 ` [dm-devel] " Christoph Hellwig
2021-01-24 10:02 ` [PATCH 01/10] brd: remove the end of device check in brd_do_bvec Christoph Hellwig
2021-01-24 10:02   ` [dm-devel] " Christoph Hellwig
2021-01-25 13:51   ` Johannes Thumshirn
2021-01-25 13:51     ` [dm-devel] " Johannes Thumshirn
2021-01-24 10:02 ` [PATCH 02/10] dcssblk: remove the end of device check in dcssblk_submit_bio Christoph Hellwig
2021-01-24 10:02   ` [dm-devel] " Christoph Hellwig
2021-01-25 13:52   ` Johannes Thumshirn
2021-01-25 13:52     ` [dm-devel] " Johannes Thumshirn
2021-01-24 10:02 ` [PATCH 03/10] block: store a block_device pointer in struct bio Christoph Hellwig
2021-01-24 10:02   ` [dm-devel] " Christoph Hellwig
2021-01-24 10:02 ` [PATCH 04/10] block: simplify submit_bio_checks a bit Christoph Hellwig
2021-01-24 10:02   ` [dm-devel] " Christoph Hellwig
2021-01-25 14:02   ` Johannes Thumshirn
2021-01-25 14:02     ` [dm-devel] " Johannes Thumshirn
2021-01-24 10:02 ` Christoph Hellwig [this message]
2021-01-24 10:02   ` [dm-devel] [PATCH 05/10] block: do not reassig ->bi_bdev when partition remapping Christoph Hellwig
2021-01-25 17:53   ` Jens Axboe
2021-01-25 17:53     ` [dm-devel] " Jens Axboe
2021-01-25 17:53     ` Jens Axboe
2021-01-25 17:55     ` Christoph Hellwig
2021-01-25 17:55       ` [dm-devel] " Christoph Hellwig
2021-01-25 17:55       ` Christoph Hellwig
2021-01-25 17:57       ` [dm-devel] " Jens Axboe
2021-01-25 18:03         ` Jens Axboe
2021-01-25 18:03           ` [dm-devel] " Jens Axboe
2021-01-25 18:03           ` Jens Axboe
2021-01-25 18:13           ` Christoph Hellwig
2021-01-25 18:13             ` [dm-devel] " Christoph Hellwig
2021-01-25 18:13             ` Christoph Hellwig
2021-01-25 18:15             ` Jens Axboe
2021-01-25 18:15               ` [dm-devel] " Jens Axboe
2021-01-25 18:15               ` Jens Axboe
2021-01-25 18:18               ` Christoph Hellwig
2021-01-25 18:18                 ` [dm-devel] " Christoph Hellwig
2021-01-25 18:18                 ` Christoph Hellwig
2021-01-25 18:19                 ` Jens Axboe
2021-01-25 18:19                   ` [dm-devel] " Jens Axboe
2021-01-25 18:19                   ` Jens Axboe
2021-01-25 18:21                   ` Christoph Hellwig
2021-01-25 18:21                     ` [dm-devel] " Christoph Hellwig
2021-01-25 18:21                     ` Christoph Hellwig
2021-01-25 18:31                     ` Jens Axboe
2021-01-25 18:31                       ` [dm-devel] " Jens Axboe
2021-01-25 18:31                       ` Jens Axboe
2021-01-24 10:02 ` [PATCH 06/10] block: use ->bi_bdev for bio based I/O accounting Christoph Hellwig
2021-01-24 10:02   ` [dm-devel] " Christoph Hellwig
2021-01-24 10:02 ` [PATCH 07/10] blk-mq: use ->bi_bdev for " Christoph Hellwig
2021-01-24 10:02   ` [dm-devel] " Christoph Hellwig
2021-01-24 10:02 ` [PATCH 08/10] block: add a disk_uevent helper Christoph Hellwig
2021-01-24 10:02   ` [dm-devel] " Christoph Hellwig
2021-01-25 14:14   ` Johannes Thumshirn
2021-01-25 14:14     ` [dm-devel] " Johannes Thumshirn
2021-01-24 10:02 ` [PATCH 09/10] block: remove DISK_PITER_REVERSE Christoph Hellwig
2021-01-24 10:02   ` [dm-devel] " Christoph Hellwig
2021-01-24 10:02 ` [PATCH 10/10] block: use an xarray for disk->part_tbl Christoph Hellwig
2021-01-24 10:02   ` [dm-devel] " Christoph Hellwig
2021-01-25 16:24 ` store a pointer to the block_device in struct bio (again) v2 Jens Axboe
2021-01-25 16:24   ` [dm-devel] " Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210124100241.1167849-6-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=colyli@suse.de \
    --cc=dm-devel@redhat.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.