All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Apply blk_partition_remap to REQ_OP_ZONE_RESET
@ 2016-11-21 19:00 Shaun Tancheff
  2016-11-21 19:11 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Shaun Tancheff @ 2016-11-21 19:00 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Shaun Tancheff, linux-block, Christoph Hellwig, Damien Le Moal,
	Hannes Reinecke, Michael T Lombardi, Shaun Tancheff

When a Reset WP is requested from a partition offset the blk_partition_remap
should be applied.

Signed-off-by: Shaun Tancheff <shaun.tancheff@seagate.com>
---
Based on for-4.10/block
---
 block/blk-core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 473dd69..3f85320 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1786,8 +1786,9 @@ static blk_qc_t blk_queue_bio(struct request_queue *q, struct bio *bio)
 static inline void blk_partition_remap(struct bio *bio)
 {
 	struct block_device *bdev = bio->bi_bdev;
+	bool remap = bio_sectors(bio) != 0 || bio_op(bio) == REQ_OP_ZONE_RESET;
 
-	if (bio_sectors(bio) && bdev != bdev->bd_contains) {
+	if (remap && bdev != bdev->bd_contains) {
 		struct hd_struct *p = bdev->bd_part;
 
 		bio->bi_iter.bi_sector += p->start_sect;
-- 
2.10.2

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

* Re: [PATCH] Apply blk_partition_remap to REQ_OP_ZONE_RESET
  2016-11-21 19:00 [PATCH] Apply blk_partition_remap to REQ_OP_ZONE_RESET Shaun Tancheff
@ 2016-11-21 19:11 ` Jens Axboe
  2016-11-21 21:52   ` [PATCH v2] " Shaun Tancheff
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2016-11-21 19:11 UTC (permalink / raw)
  To: Shaun Tancheff
  Cc: linux-block, Christoph Hellwig, Damien Le Moal, Hannes Reinecke,
	Michael T Lombardi, Shaun Tancheff

On 11/21/2016 12:00 PM, Shaun Tancheff wrote:
> When a Reset WP is requested from a partition offset the blk_partition_remap
> should be applied.

You need to provide a better explanation in your commit message, and
also put a comment in the code. A good commit message explans WHY
there's a need for the patch.

-- 
Jens Axboe

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

* [PATCH v2] Apply blk_partition_remap to REQ_OP_ZONE_RESET
  2016-11-21 19:11 ` Jens Axboe
@ 2016-11-21 21:52   ` Shaun Tancheff
  2016-11-21 22:07     ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Shaun Tancheff @ 2016-11-21 21:52 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Shaun Tancheff, linux-block, Christoph Hellwig, Damien Le Moal,
	Hannes Reinecke, Michael T Lombardi, Shaun Tancheff

If a ZBC device is partitioned and operations are performed on the partition
the zone information is rebased to the partition, however the zone reset
is not mapped from the partition to device as are other operations.

This causes the API (report zones / reset zone) to be unbalanced in this
regard. Checking for the zone reset op code explicitly will balance the
API.

Signed-off-by: Shaun Tancheff <shaun.tancheff@seagate.com>
---
v2: 
 - Moved conditional check
 - Added comments and update commit message

Based on for-4.10/block
---
 block/blk-core.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 473dd69..6c4a425 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1787,7 +1787,12 @@ static inline void blk_partition_remap(struct bio *bio)
 {
 	struct block_device *bdev = bio->bi_bdev;
 
-	if (bio_sectors(bio) && bdev != bdev->bd_contains) {
+	/*
+	 * Zone reset does not include bi_size so bio_sectors() is always 0.
+	 * Include a test for the reset op code and perform the remap if needed.
+	 */
+	if (bdev != bdev->bd_contains &&
+	    (bio_sectors(bio) || bio_op(bio) == REQ_OP_ZONE_RESET)) {
 		struct hd_struct *p = bdev->bd_part;
 
 		bio->bi_iter.bi_sector += p->start_sect;
-- 
2.10.2

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

* Re: [PATCH v2] Apply blk_partition_remap to REQ_OP_ZONE_RESET
  2016-11-21 21:52   ` [PATCH v2] " Shaun Tancheff
@ 2016-11-21 22:07     ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2016-11-21 22:07 UTC (permalink / raw)
  To: Shaun Tancheff
  Cc: linux-block, Christoph Hellwig, Damien Le Moal, Hannes Reinecke,
	Michael T Lombardi, Shaun Tancheff

On 11/21/2016 02:52 PM, Shaun Tancheff wrote:
> If a ZBC device is partitioned and operations are performed on the partition
> the zone information is rebased to the partition, however the zone reset
> is not mapped from the partition to device as are other operations.
>
> This causes the API (report zones / reset zone) to be unbalanced in this
> regard. Checking for the zone reset op code explicitly will balance the
> API.

Much better, thanks. Applied for 4.10.

-- 
Jens Axboe

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

end of thread, other threads:[~2016-11-21 22:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-21 19:00 [PATCH] Apply blk_partition_remap to REQ_OP_ZONE_RESET Shaun Tancheff
2016-11-21 19:11 ` Jens Axboe
2016-11-21 21:52   ` [PATCH v2] " Shaun Tancheff
2016-11-21 22:07     ` Jens Axboe

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.