diff mbox series

scsi: sd_zbc: Fix zone information messages

Message ID 20190130065458.17363-1-damien.lemoal@wdc.com (mailing list archive)
State Mainlined
Commit 88fc41c407158a7d2eaa4b2f7cfa289749d456c6
Headers show
Series scsi: sd_zbc: Fix zone information messages | expand

Commit Message

Damien Le Moal Jan. 30, 2019, 6:54 a.m. UTC
Commit bf5054569653 ("block: Introduce blk_revalidate_disk_zones()")
inadvertently broke the message output of sd_zbc_print_zones() because
the zone information initialization of the scsi disk structure was
moved to the second scan run while sd_zbc_print_zones() is called on
the first scan. This leads to the following incorrect message to be
printed for any ZBC or ZAC zoned disks.

"...[sdX] 4294967295 zones of 0 logical blocks + 1 runt zone"

Fix this by initializing sdkp zone size and number of zones early on the
first scan. This does not impact the execution of
blk_revalidate_zones(). This functions is still called only once the
block device capacity is set on the second revalidate run on boot, or if
the disk zone configuration changed (i.e. the disk changed).

Fixes: bf5054569653 ("block: Introduce blk_revalidate_disk_zones()")
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/scsi/sd_zbc.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Damien Le Moal Feb. 3, 2019, 12:10 p.m. UTC | #1
Martin,

Any comment on this patch ?

On 2019/01/30 7:55, Damien Le Moal wrote:
> Commit bf5054569653 ("block: Introduce blk_revalidate_disk_zones()")
> inadvertently broke the message output of sd_zbc_print_zones() because
> the zone information initialization of the scsi disk structure was
> moved to the second scan run while sd_zbc_print_zones() is called on
> the first scan. This leads to the following incorrect message to be
> printed for any ZBC or ZAC zoned disks.
> 
> "...[sdX] 4294967295 zones of 0 logical blocks + 1 runt zone"
> 
> Fix this by initializing sdkp zone size and number of zones early on the
> first scan. This does not impact the execution of
> blk_revalidate_zones(). This functions is still called only once the
> block device capacity is set on the second revalidate run on boot, or if
> the disk zone configuration changed (i.e. the disk changed).
> 
> Fixes: bf5054569653 ("block: Introduce blk_revalidate_disk_zones()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>  drivers/scsi/sd_zbc.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index 83365b29a4d8..fff86940388b 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -462,12 +462,16 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)
>  	sdkp->device->use_10_for_rw = 0;
>  
>  	/*
> -	 * If something changed, revalidate the disk zone bitmaps once we have
> -	 * the capacity, that is on the second revalidate execution during disk
> -	 * scan and always during normal revalidate.
> +	 * Revalidate the disk zone bitmaps once the block device capacity is
> +	 * set on the second revalidate execution during disk scan and if
> +	 * something changed when executing a normal revalidate.
>  	 */
> -	if (sdkp->first_scan)
> +	if (sdkp->first_scan) {
> +		sdkp->zone_blocks = zone_blocks;
> +		sdkp->nr_zones = nr_zones;
>  		return 0;
> +	}
> +
>  	if (sdkp->zone_blocks != zone_blocks ||
>  	    sdkp->nr_zones != nr_zones ||
>  	    disk->queue->nr_zones != nr_zones) {
>
Martin K. Petersen Feb. 5, 2019, 3:06 a.m. UTC | #2
Damien,

> Commit bf5054569653 ("block: Introduce blk_revalidate_disk_zones()")
> inadvertently broke the message output of sd_zbc_print_zones() because
> the zone information initialization of the scsi disk structure was
> moved to the second scan run while sd_zbc_print_zones() is called on
> the first scan. This leads to the following incorrect message to be
> printed for any ZBC or ZAC zoned disks.

Applied to 5.0/scsi-fixes, thanks!
diff mbox series

Patch

diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index 83365b29a4d8..fff86940388b 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -462,12 +462,16 @@  int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)
 	sdkp->device->use_10_for_rw = 0;
 
 	/*
-	 * If something changed, revalidate the disk zone bitmaps once we have
-	 * the capacity, that is on the second revalidate execution during disk
-	 * scan and always during normal revalidate.
+	 * Revalidate the disk zone bitmaps once the block device capacity is
+	 * set on the second revalidate execution during disk scan and if
+	 * something changed when executing a normal revalidate.
 	 */
-	if (sdkp->first_scan)
+	if (sdkp->first_scan) {
+		sdkp->zone_blocks = zone_blocks;
+		sdkp->nr_zones = nr_zones;
 		return 0;
+	}
+
 	if (sdkp->zone_blocks != zone_blocks ||
 	    sdkp->nr_zones != nr_zones ||
 	    disk->queue->nr_zones != nr_zones) {