Patch "scsi: sd: Fix wrong zone_write_granularity value during revalidate" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    scsi: sd: Fix wrong zone_write_granularity value during revalidate

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     scsi-sd-fix-wrong-zone_write_granularity-value-durin.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 68010ef60bc62baf9fd99e4d1da7f6458910c425
Author: Shin'ichiro Kawasaki <shinichiro.kawasaki@xxxxxxx>
Date:   Mon Mar 6 15:30:24 2023 +0900

    scsi: sd: Fix wrong zone_write_granularity value during revalidate
    
    [ Upstream commit 288b3271d920c9ba949c3bab0f749f4cecc70e09 ]
    
    When the sd driver revalidates host-managed SMR disks, it calls
    disk_set_zoned() which changes the zone_write_granularity attribute value
    to the logical block size regardless of the device type. After that, the sd
    driver overwrites the value in sd_zbc_read_zone() with the physical block
    size, since ZBC/ZAC requires this for host-managed disks. Between the calls
    to disk_set_zoned() and sd_zbc_read_zone(), there exists a window where the
    attribute shows the logical block size as the zone_write_granularity value,
    which is wrong for host-managed disks. The duration of the window is from
    20ms to 200ms, depending on report zone command execution time.
    
    To avoid the wrong zone_write_granularity value between disk_set_zoned()
    and sd_zbc_read_zone(), modify the value not in sd_zbc_read_zone() but
    just after disk_set_zoned() call.
    
    Fixes: a805a4fa4fa3 ("block: introduce zone_write_granularity limit")
    Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@xxxxxxx>
    Link: https://lore.kernel.org/r/20230306063024.3376959-1-shinichiro.kawasaki@xxxxxxx
    Reviewed-by: Damien Le Moal <damien.lemoal@xxxxxxxxxxxxxxxxxx>
    Reviewed-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx>
    Reviewed-by: Bart Van Assche <bvanassche@xxxxxxx>
    Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index eb76ba0550216..e934779bf05c8 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2933,8 +2933,13 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp)
 	}
 
 	if (sdkp->device->type == TYPE_ZBC) {
-		/* Host-managed */
+		/*
+		 * Host-managed: Per ZBC and ZAC specifications, writes in
+		 * sequential write required zones of host-managed devices must
+		 * be aligned to the device physical block size.
+		 */
 		disk_set_zoned(sdkp->disk, BLK_ZONED_HM);
+		blk_queue_zone_write_granularity(q, sdkp->physical_block_size);
 	} else {
 		sdkp->zoned = zoned;
 		if (sdkp->zoned == 1) {
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index bd15624c63228..4c35b4a916355 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -956,14 +956,6 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
 	disk_set_max_active_zones(disk, 0);
 	nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks);
 
-	/*
-	 * Per ZBC and ZAC specifications, writes in sequential write required
-	 * zones of host-managed devices must be aligned to the device physical
-	 * block size.
-	 */
-	if (blk_queue_zoned_model(q) == BLK_ZONED_HM)
-		blk_queue_zone_write_granularity(q, sdkp->physical_block_size);
-
 	sdkp->early_zone_info.nr_zones = nr_zones;
 	sdkp->early_zone_info.zone_blocks = zone_blocks;
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux