• Damien Le Moal's avatar
    block: Allow zero value of max_zone_append_sectors queue limit · ccdbf0aa
    Damien Le Moal authored
    In preparation for adding a generic zone append emulation using zone
    write plugging, allow device drivers supporting zoned block device to
    set a the max_zone_append_sectors queue limit of a device to 0 to
    indicate the lack of native support for zone append operations and that
    the block layer should emulate these operations using regular write
    operations.
    
    blk_queue_max_zone_append_sectors() is modified to allow passing 0 as
    the max_zone_append_sectors argument. The function
    queue_max_zone_append_sectors() is also modified to ensure that the
    minimum of the max_hw_sectors and chunk_sectors limit is used whenever
    the max_zone_append_sectors limit is 0. This minimum is consistent with
    the value set for the max_zone_append_sectors limit by the function
    blk_validate_zoned_limits() when limits for a queue are validated.
    
    The helper functions queue_emulates_zone_append() and
    bdev_emulates_zone_append() are added to test if a queue (or block
    device) emulates zone append operations.
    
    In order for blk_revalidate_disk_zones() to accept zoned block devices
    relying on zone append emulation, the direct check to the
    max_zone_append_sectors queue limit of the disk is replaced by a check
    using the value returned by queue_max_zone_append_sectors(). Similarly,
    queue_zone_append_max_show() is modified to use the same accessor so
    that the sysfs attribute advertizes the non-zero limit that will be
    used, regardless if it is for native or emulated commands.
    
    For stacking drivers, a top device should not need to care if the
    underlying devices have native or emulated zone append operations.
    blk_stack_limits() is thus modified to set the top device
    max_zone_append_sectors limit using the new accessor
    queue_limits_max_zone_append_sectors(). queue_max_zone_append_sectors()
    is modified to use this function as well. Stacking drivers that require
    zone append emulation, e.g. dm-crypt, can still request this feature by
    calling blk_queue_max_zone_append_sectors() with a 0 limit.
    Signed-off-by: default avatarDamien Le Moal <dlemoal@kernel.org>
    Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
    Tested-by: default avatarHans Holmberg <hans.holmberg@wdc.com>
    Tested-by: default avatarDennis Maisenbacher <dennis.maisenbacher@wdc.com>
    Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
    Link: https://lore.kernel.org/r/20240408014128.205141-10-dlemoal@kernel.orgSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
    ccdbf0aa
blk-settings.c 35.6 KB