Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

null_blk: Introduce zone_append_max_sectors attribute

Add the zone_append_max_sectors configfs attribute and module parameter
to allow configuring the maximum number of 512B sectors of zone append
operations. This attribute is meaningful only for zoned null block
devices.

If not specified, the default is unchanged and the zoned device max
append sectors limit is set to the device max sectors limit.
If a non 0 value is used for this attribute, which is the default,
then native support for zone append operations is enabled.
Setting a 0 value disables native zone append operations support to
instead use the block layer emulation.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Hans Holmberg <hans.holmberg@wdc.com>
Tested-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20240408014128.205141-17-dlemoal@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Damien Le Moal and committed by
Jens Axboe
997a1f08 b66f79b7

+27 -4
+9 -1
drivers/block/null_blk/main.c
··· 253 253 module_param_named(zone_max_active, g_zone_max_active, uint, 0444); 254 254 MODULE_PARM_DESC(zone_max_active, "Maximum number of active zones when block device is zoned. Default: 0 (no limit)"); 255 255 256 + static int g_zone_append_max_sectors = INT_MAX; 257 + module_param_named(zone_append_max_sectors, g_zone_append_max_sectors, int, 0444); 258 + MODULE_PARM_DESC(zone_append_max_sectors, 259 + "Maximum size of a zone append command (in 512B sectors). Specify 0 for zone append emulation"); 260 + 256 261 static struct nullb_device *null_alloc_dev(void); 257 262 static void null_free_dev(struct nullb_device *dev); 258 263 static void null_del_dev(struct nullb *nullb); ··· 441 436 NULLB_DEVICE_ATTR(zone_nr_conv, uint, NULL); 442 437 NULLB_DEVICE_ATTR(zone_max_open, uint, NULL); 443 438 NULLB_DEVICE_ATTR(zone_max_active, uint, NULL); 439 + NULLB_DEVICE_ATTR(zone_append_max_sectors, uint, NULL); 444 440 NULLB_DEVICE_ATTR(virt_boundary, bool, NULL); 445 441 NULLB_DEVICE_ATTR(no_sched, bool, NULL); 446 442 NULLB_DEVICE_ATTR(shared_tags, bool, NULL); ··· 586 580 &nullb_device_attr_zone_nr_conv, 587 581 &nullb_device_attr_zone_max_open, 588 582 &nullb_device_attr_zone_max_active, 583 + &nullb_device_attr_zone_append_max_sectors, 589 584 &nullb_device_attr_zone_readonly, 590 585 &nullb_device_attr_zone_offline, 591 586 &nullb_device_attr_virt_boundary, ··· 678 671 "shared_tags,size,submit_queues,use_per_node_hctx," 679 672 "virt_boundary,zoned,zone_capacity,zone_max_active," 680 673 "zone_max_open,zone_nr_conv,zone_offline,zone_readonly," 681 - "zone_size\n"); 674 + "zone_size,zone_append_max_sectors\n"); 682 675 } 683 676 684 677 CONFIGFS_ATTR_RO(memb_group_, features); ··· 758 751 dev->zone_nr_conv = g_zone_nr_conv; 759 752 dev->zone_max_open = g_zone_max_open; 760 753 dev->zone_max_active = g_zone_max_active; 754 + dev->zone_append_max_sectors = g_zone_append_max_sectors; 761 755 dev->virt_boundary = g_virt_boundary; 762 756 dev->no_sched = g_no_sched; 763 757 dev->shared_tags = g_shared_tags;
+1
drivers/block/null_blk/null_blk.h
··· 82 82 unsigned int zone_nr_conv; /* number of conventional zones */ 83 83 unsigned int zone_max_open; /* max number of open zones */ 84 84 unsigned int zone_max_active; /* max number of active zones */ 85 + unsigned int zone_append_max_sectors; /* Max sectors per zone append command */ 85 86 unsigned int submit_queues; /* number of submission queues */ 86 87 unsigned int prev_submit_queues; /* number of submission queues before change */ 87 88 unsigned int poll_queues; /* number of IOPOLL submission queues */
+17 -3
drivers/block/null_blk/zoned.c
··· 103 103 dev->zone_nr_conv); 104 104 } 105 105 106 + dev->zone_append_max_sectors = 107 + min(ALIGN_DOWN(dev->zone_append_max_sectors, 108 + dev->blocksize >> SECTOR_SHIFT), 109 + zone_capacity_sects); 110 + 106 111 /* Max active zones has to be < nbr of seq zones in order to be enforceable */ 107 112 if (dev->zone_max_active >= dev->nr_zones - dev->zone_nr_conv) { 108 113 dev->zone_max_active = 0; ··· 159 154 160 155 lim->zoned = true; 161 156 lim->chunk_sectors = dev->zone_size_sects; 162 - lim->max_zone_append_sectors = dev->zone_size_sects; 157 + lim->max_zone_append_sectors = dev->zone_append_max_sectors; 163 158 lim->max_open_zones = dev->zone_max_open; 164 159 lim->max_active_zones = dev->zone_max_active; 165 160 return 0; ··· 168 163 int null_register_zoned_dev(struct nullb *nullb) 169 164 { 170 165 struct request_queue *q = nullb->q; 166 + struct gendisk *disk = nullb->disk; 171 167 172 168 blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q); 173 - nullb->disk->nr_zones = bdev_nr_zones(nullb->disk->part0); 174 - return blk_revalidate_disk_zones(nullb->disk, NULL); 169 + disk->nr_zones = bdev_nr_zones(disk->part0); 170 + 171 + pr_info("%s: using %s zone append\n", 172 + disk->disk_name, 173 + queue_emulates_zone_append(q) ? "emulated" : "native"); 174 + 175 + return blk_revalidate_disk_zones(disk, NULL); 175 176 } 176 177 177 178 void null_free_zoned_dev(struct nullb_device *dev) ··· 375 364 blk_status_t ret; 376 365 377 366 trace_nullb_zone_op(cmd, zno, zone->cond); 367 + 368 + if (WARN_ON_ONCE(append && !dev->zone_append_max_sectors)) 369 + return BLK_STS_IOERR; 378 370 379 371 if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) { 380 372 if (append)