Apply blk_partition_remap to REQ_OP_ZONE_RESET
PATCH 1/1 Apply blk_partition_remap to REQ_OP_ZONE_RESET
When a Reset WP is requested from a partition offset the blk_partition_remap should be applied.
---
Based on for-4.10/block
--- block/blk-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-core.c +2 -1
@@ -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;
Signature · 1 line
2.10.2
Jens Axboe
maintainerQuoted 2 lines · Shaun Tancheff
When a Reset WP is requested from a partition offset the
blk_partition_remapshould 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.
Signature · 1 line
Jens Axboe
PATCH v2 1/1 Apply blk_partition_remap to REQ_OP_ZONE_RESET
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.
---
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(-)
block/blk-core.c +6 -1
@@ -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;
Signature · 1 line
2.10.2
Jens Axboe
maintainerQuoted 7 lines · 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.
Much better, thanks. Applied for 4.10.
Signature · 1 line
Jens Axboe