Skip to content

Commit f4d5dc3

Browse files
damien-lemoalaxboe
authored andcommitted
null_blk: Introduce the zone_full parameter
Allow creating a zoned null_blk device with the initial state of its sequential write required zones to be FULL. This is convenient to avoid having to first write these zones to perform read performance evaluation or test zone management operations such as zone reset (and zone reset all). Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent dd54fd4 commit f4d5dc3

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

drivers/block/null_blk/main.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@ module_param_named(zone_append_max_sectors, g_zone_append_max_sectors, int, 0444
262262
MODULE_PARM_DESC(zone_append_max_sectors,
263263
"Maximum size of a zone append command (in 512B sectors). Specify 0 for zone append emulation");
264264

265+
static bool g_zone_full;
266+
module_param_named(zone_full, g_zone_full, bool, S_IRUGO);
267+
MODULE_PARM_DESC(zone_full, "Initialize the sequential write required zones of a zoned device to be full. Default: false");
268+
265269
static struct nullb_device *null_alloc_dev(void);
266270
static void null_free_dev(struct nullb_device *dev);
267271
static void null_del_dev(struct nullb *nullb);
@@ -458,6 +462,7 @@ NULLB_DEVICE_ATTR(zone_nr_conv, uint, NULL);
458462
NULLB_DEVICE_ATTR(zone_max_open, uint, NULL);
459463
NULLB_DEVICE_ATTR(zone_max_active, uint, NULL);
460464
NULLB_DEVICE_ATTR(zone_append_max_sectors, uint, NULL);
465+
NULLB_DEVICE_ATTR(zone_full, bool, NULL);
461466
NULLB_DEVICE_ATTR(virt_boundary, bool, NULL);
462467
NULLB_DEVICE_ATTR(no_sched, bool, NULL);
463468
NULLB_DEVICE_ATTR(shared_tags, bool, NULL);
@@ -610,6 +615,7 @@ static struct configfs_attribute *nullb_device_attrs[] = {
610615
&nullb_device_attr_zone_append_max_sectors,
611616
&nullb_device_attr_zone_readonly,
612617
&nullb_device_attr_zone_offline,
618+
&nullb_device_attr_zone_full,
613619
&nullb_device_attr_virt_boundary,
614620
&nullb_device_attr_no_sched,
615621
&nullb_device_attr_shared_tags,
@@ -700,7 +706,7 @@ static ssize_t memb_group_features_show(struct config_item *item, char *page)
700706
"shared_tags,size,submit_queues,use_per_node_hctx,"
701707
"virt_boundary,zoned,zone_capacity,zone_max_active,"
702708
"zone_max_open,zone_nr_conv,zone_offline,zone_readonly,"
703-
"zone_size,zone_append_max_sectors\n");
709+
"zone_size,zone_append_max_sectors,zone_full\n");
704710
}
705711

706712
CONFIGFS_ATTR_RO(memb_group_, features);
@@ -781,6 +787,7 @@ static struct nullb_device *null_alloc_dev(void)
781787
dev->zone_max_open = g_zone_max_open;
782788
dev->zone_max_active = g_zone_max_active;
783789
dev->zone_append_max_sectors = g_zone_append_max_sectors;
790+
dev->zone_full = g_zone_full;
784791
dev->virt_boundary = g_virt_boundary;
785792
dev->no_sched = g_no_sched;
786793
dev->shared_tags = g_shared_tags;

drivers/block/null_blk/null_blk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ struct nullb_device {
101101
bool memory_backed; /* if data is stored in memory */
102102
bool discard; /* if support discard */
103103
bool zoned; /* if device is zoned */
104+
bool zone_full; /* Initialize zones to be full */
104105
bool virt_boundary; /* virtual boundary on/off for the device */
105106
bool no_sched; /* no IO scheduler for the device */
106107
bool shared_tags; /* share tag set between devices for blk-mq */

drivers/block/null_blk/zoned.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,21 @@ int null_init_zoned_dev(struct nullb_device *dev,
145145
zone = &dev->zones[i];
146146

147147
null_init_zone_lock(dev, zone);
148-
zone->start = zone->wp = sector;
148+
zone->start = sector;
149149
if (zone->start + dev->zone_size_sects > dev_capacity_sects)
150150
zone->len = dev_capacity_sects - zone->start;
151151
else
152152
zone->len = dev->zone_size_sects;
153153
zone->capacity =
154154
min_t(sector_t, zone->len, zone_capacity_sects);
155155
zone->type = BLK_ZONE_TYPE_SEQWRITE_REQ;
156-
zone->cond = BLK_ZONE_COND_EMPTY;
156+
if (dev->zone_full) {
157+
zone->cond = BLK_ZONE_COND_FULL;
158+
zone->wp = zone->start + zone->capacity;
159+
} else{
160+
zone->cond = BLK_ZONE_COND_EMPTY;
161+
zone->wp = zone->start;
162+
}
157163

158164
sector += dev->zone_size_sects;
159165
}

0 commit comments

Comments
 (0)