• Damien Le Moal's avatar
    null_blk: Fix zoned command handling · 9dd44c7e
    Damien Le Moal authored
    For write operations issued to a null_blk device with zoned mode
    enabled, the state and write pointer position of the zone targeted by
    the command should be checked before badblocks and memory backing
    are handled as the write may be first failed due to, for instance, a
    sector position not aligned with the zone write pointer. This order of
    checking for errors reflects more accuratly the behavior of physical
    zoned devices.
    
    Furthermore, the write pointer position of the target zone should be
    incremented only and only if no errors are reported by badblocks and
    memory backing handling.
    
    To fix this, introduce the small helper function null_process_cmd()
    which execute null_handle_badblocks() and null_handle_memory_backed()
    and use this function in null_zone_write() to correctly handle write
    requests to zoned null devices depending on the type and state of the
    write target zone. Also call this function in null_handle_zoned() to
    process read requests to zoned null devices.
    
    null_process_cmd() is called directly from null_handle_cmd() for
    regular null devices, resulting in no functional change for these type
    of devices. To have symmetric names, the function null_handle_zoned()
    is renamed to null_process_zoned_cmd().
    Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
    Reviewed-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    9dd44c7e
null_blk_main.c 46.3 KB