• Damien Le Moal's avatar
    scsi: sd_zbc: Improve zone revalidation · a3d8a257
    Damien Le Moal authored
    Currently, for zoned disks, since blk_revalidate_disk_zones() requires the
    disk capacity to be set already to operate correctly, zones revalidation
    can only be done on the second revalidate scan once the gendisk capacity is
    set at the end of the first scan. As a result, if zone revalidation fails,
    there is no second chance to recover from the failure and the disk capacity
    is changed to 0, with the disk left unusable.
    
    This can be improved by shuffling around code, specifically, by moving the
    call to sd_zbc_revalidate_zones() from sd_zbc_read_zones() to the end of
    sd_revalidate_disk(), after set_capacity_revalidate_and_notify() is called
    to set the gendisk capacity. With this change, if sd_zbc_revalidate_zones()
    fails on the first scan, the second scan will call it again to recover, if
    possible.
    
    Using the new struct scsi_disk fields rev_nr_zones and rev_zone_blocks,
    sd_zbc_revalidate_zones() does actual work only if it detects a change with
    the disk zone configuration. This means that for a successful zones
    revalidation on the first scan, the second scan will not cause another
    heavy full check.
    
    While at it, remove the unecesary "extern" declaration of
    sd_zbc_read_zones().
    
    Link: https://lore.kernel.org/r/20200731054928.668547-1-damien.lemoal@wdc.comReviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
    Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
    Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
    a3d8a257
sd_zbc.c 20.2 KB