[PATCH 3/5] block: nullblk: Set zone limits before revalidating zones

Damien Le Moal
2023-06-29T06:26:25Z

In null_register_zoned_dev(), call blk_queue_chunk_sectors() and
blk_queue_max_zone_append_sectors() to respectively set the device zone
size and maximum zone append sector limit before executing
blk_revalidate_disk_zones() to allow this function to check zone limits.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
drivers/block/null_blk/zoned.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
index 635ce0648133..84fe0d92087f 100644
--- a/drivers/block/null_blk/zoned.c
+++ b/drivers/block/null_blk/zoned.c
@@ -160,22 +160,17 @@ int null_register_zoned_dev(struct nullb *nullb)
struct request_queue *q = nullb->q;

disk_set_zoned(nullb->disk, BLK_ZONED_HM);
+ disk_set_max_open_zones(nullb->disk, dev->zone_max_open);
+ disk_set_max_active_zones(nullb->disk, dev->zone_max_active);
+
blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
blk_queue_required_elevator_features(q, ELEVATOR_F_ZBD_SEQ_WRITE);
-
- if (queue_is_mq(q)) {
- int ret = blk_revalidate_disk_zones(nullb->disk, NULL);
-
- if (ret)
- return ret;
- } else {
- blk_queue_chunk_sectors(q, dev->zone_size_sects);
- nullb->disk->nr_zones = bdev_nr_zones(nullb->disk->part0);
- }
-
+ blk_queue_chunk_sectors(q, dev->zone_size_sects);
blk_queue_max_zone_append_sectors(q, dev->zone_size_sects);
- disk_set_max_open_zones(nullb->disk, dev->zone_max_open);
- disk_set_max_active_zones(nullb->disk, dev->zone_max_active);
+ nullb->disk->nr_zones = bdev_nr_zones(nullb->disk->part0);
+
+ if (queue_is_mq(q))
+ return blk_revalidate_disk_zones(nullb->disk, NULL);

return 0;
}
--
2.41.0