diff mbox series

[1/2] scsi: sd_zbc: do not enforce READ/WRITE (16) on host-aware devices

Message ID 20221109025941.1594612-2-shinichiro.kawasaki@wdc.com (mailing list archive)
State Superseded
Headers show
Series scsi: sd: use READ/WRITE/SYNC (16) commands per ZBC | expand

Commit Message

Shin'ichiro Kawasaki Nov. 9, 2022, 2:59 a.m. UTC
ZBC Zoned Block Commands specification mandates READ (16) and WRITE (16)
commands only for host-managed zoned block devices. It does not mandate
the commands for host-aware zoned block devices. However, current
sd_zbc_read_zones() code assumes the commands were mandated for host-
aware devices also and enforces the commands. If the host-aware drives
do not support the commands, they may fail.

To conform to the ZBC specification and to avoid the failure, check
device type and modify use_16_for_rw and use_10_for_rw flags only for
host-managed zoned block devices, so that the READ (16) and WRITE (16)
commands are not enforced on host-aware zoned block devices.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 drivers/scsi/sd_zbc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Damien Le Moal Nov. 9, 2022, 5:17 a.m. UTC | #1
On 11/9/22 11:59, Shin'ichiro Kawasaki wrote:
> ZBC Zoned Block Commands specification mandates READ (16) and WRITE (16)
> commands only for host-managed zoned block devices. It does not mandate
> the commands for host-aware zoned block devices. However, current
> sd_zbc_read_zones() code assumes the commands were mandated for host-
> aware devices also and enforces the commands. If the host-aware drives
> do not support the commands, they may fail.
> 
> To conform to the ZBC specification and to avoid the failure, check
> device type and modify use_16_for_rw and use_10_for_rw flags only for
> host-managed zoned block devices, so that the READ (16) and WRITE (16)
> commands are not enforced on host-aware zoned block devices.
> 
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> ---
>  drivers/scsi/sd_zbc.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index bd15624c6322..4717a55dbf35 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -921,9 +921,11 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
>  		return 0;
>  	}
>  
> -	/* READ16/WRITE16 is mandatory for ZBC disks */
> -	sdkp->device->use_16_for_rw = 1;
> -	sdkp->device->use_10_for_rw = 0;
> +	/* READ16/WRITE16 is mandatory for host-managed devices */
> +	if (sdkp->device->type == TYPE_ZBC) {
> +		sdkp->device->use_16_for_rw = 1;
> +		sdkp->device->use_10_for_rw = 0;
> +	}
>  
>  	if (!blk_queue_is_zoned(q)) {
>  		/*

Looks good to me.

Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
diff mbox series

Patch

diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index bd15624c6322..4717a55dbf35 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -921,9 +921,11 @@  int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
 		return 0;
 	}
 
-	/* READ16/WRITE16 is mandatory for ZBC disks */
-	sdkp->device->use_16_for_rw = 1;
-	sdkp->device->use_10_for_rw = 0;
+	/* READ16/WRITE16 is mandatory for host-managed devices */
+	if (sdkp->device->type == TYPE_ZBC) {
+		sdkp->device->use_16_for_rw = 1;
+		sdkp->device->use_10_for_rw = 0;
+	}
 
 	if (!blk_queue_is_zoned(q)) {
 		/*