• Damien Le Moal's avatar
    dm: Use the block layer zone append emulation · f211268e
    Damien Le Moal authored
    For targets requiring zone append operation emulation with regular
    writes (e.g. dm-crypt), we can use the block layer emulation provided by
    zone write plugging. Remove DM implemented zone append emulation and
    enable the block layer one.
    
    This is done by setting the max_zone_append_sectors limit of the
    mapped device queue to 0 for mapped devices that have a target table
    that cannot support native zone append operations (e.g. dm-crypt).
    Such mapped devices are flagged with the DMF_EMULATE_ZONE_APPEND flag.
    dm_split_and_process_bio() is modified to execute
    blk_zone_write_plug_bio() for such device to let the block layer
    transform zone append operations into regular writes.  This is done
    after ensuring that the submitted BIO is split if it straddles zone
    boundaries. Both changes are implemented unsing the inline helpers
    dm_zone_write_plug_bio() and dm_zone_bio_needs_split() respectively.
    
    dm_revalidate_zones() is also modified to use the block layer provided
    function blk_revalidate_disk_zones() so that all zone resources needed
    for zone append emulation are initialized by the block layer without DM
    core needing to do anything. Since the device table is not yet live when
    dm_revalidate_zones() is executed, enabling the use of
    blk_revalidate_disk_zones() requires adding a pointer to the device
    table in struct mapped_device. This avoids errors in
    dm_blk_report_zones() trying to get the table with dm_get_live_table().
    The mapped device table pointer is set to the table passed as argument
    to dm_revalidate_zones() before calling blk_revalidate_disk_zones() and
    reset to NULL after this function returns to restore the live table
    handling for user call of report zones.
    
    All the code related to zone append emulation is removed from
    dm-zone.c. This leads to simplifications of the functions __map_bio()
    and dm_zone_endio(). This later function now only needs to deal with
    completions of real zone append operations for targets that support it.
    Signed-off-by: default avatarDamien Le Moal <dlemoal@kernel.org>
    Reviewed-by: default avatarMike Snitzer <snitzer@kernel.org>
    Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
    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-13-dlemoal@kernel.orgSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
    f211268e
dm.h 7.11 KB