scsi: sd_zbc: Improve zone revalidation
authorDamien Le Moal <damien.lemoal@wdc.com>
Fri, 31 Jul 2020 05:49:28 +0000 (14:49 +0900)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 5 Aug 2020 00:56:56 +0000 (20:56 -0400)
commita3d8a2573687bc8955986e4e011ebfe19cc71054
tree674599effc6689d8d26f4ac82038d1ebbcf930e9
parentec007ef40abb6a164d148b0dc19789a7a2de2cc8
scsi: sd_zbc: Improve zone revalidation

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.com
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/sd.c
drivers/scsi/sd.h
drivers/scsi/sd_zbc.c