提交 42c59077 编写于 作者: S Shin'ichiro Kawasaki 提交者: Martin K. Petersen

scsi: sd: Use 16-byte SYNCHRONIZE CACHE on ZBC devices

ZBC Zoned Block Commands specification mandates SYNCHRONIZE CACHE(16) for
host-managed zoned block devices, but does not mandate SYNCHRONIZE
CACHE(10). Call SYNCHRONIZE CACHE(16) in place of SYNCHRONIZE CACHE(10) to
ensure that the command is always supported. For this purpose, add
use_16_for_sync flag to struct scsi_device in same manner as use_16_for_rw
flag.

To be precise, ZBC does not mandate SYNCHRONIZE CACHE(16) for host-aware
zoned block devices. However, modern devices should support 16-byte
commands. Hence, call SYNCHRONIZE CACHE (16) on both types of ZBC devices,
host-aware and host-managed. Of note is that READ(16) and WRITE(16) have
same story and they are already called for both types of ZBC devices.

Another note is that this patch depends on the fix commit ea045fd3
("ata: libata-scsi: fix SYNCHRONIZE CACHE (16) command failure").
Signed-off-by: NShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Link: https://lore.kernel.org/r/20221115002905.1709006-1-shinichiro.kawasaki@wdc.comReviewed-by: NDamien Le Moal <damien.lemoal@opendource.wdc.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
上级 e6f108bf
......@@ -1026,8 +1026,13 @@ static blk_status_t sd_setup_flush_cmnd(struct scsi_cmnd *cmd)
/* flush requests don't perform I/O, zero the S/G table */
memset(&cmd->sdb, 0, sizeof(cmd->sdb));
cmd->cmnd[0] = SYNCHRONIZE_CACHE;
cmd->cmd_len = 10;
if (cmd->device->use_16_for_sync) {
cmd->cmnd[0] = SYNCHRONIZE_CACHE_16;
cmd->cmd_len = 16;
} else {
cmd->cmnd[0] = SYNCHRONIZE_CACHE;
cmd->cmd_len = 10;
}
cmd->transfersize = 0;
cmd->allowed = sdkp->max_retries;
......@@ -1587,9 +1592,12 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
sshdr = &my_sshdr;
for (retries = 3; retries > 0; --retries) {
unsigned char cmd[10] = { 0 };
unsigned char cmd[16] = { 0 };
cmd[0] = SYNCHRONIZE_CACHE;
if (sdp->use_16_for_sync)
cmd[0] = SYNCHRONIZE_CACHE_16;
else
cmd[0] = SYNCHRONIZE_CACHE;
/*
* Leave the rest of the command zero to indicate
* flush everything.
......
......@@ -921,9 +921,10 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
return 0;
}
/* READ16/WRITE16 is mandatory for ZBC disks */
/* READ16/WRITE16/SYNC16 is mandatory for ZBC devices */
sdkp->device->use_16_for_rw = 1;
sdkp->device->use_10_for_rw = 0;
sdkp->device->use_16_for_sync = 1;
if (!blk_queue_is_zoned(q)) {
/*
......
......@@ -184,6 +184,7 @@ struct scsi_device {
unsigned no_report_opcodes:1; /* no REPORT SUPPORTED OPERATION CODES */
unsigned no_write_same:1; /* no WRITE SAME command */
unsigned use_16_for_rw:1; /* Use read/write(16) over read/write(10) */
unsigned use_16_for_sync:1; /* Use sync (16) over sync (10) */
unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */
unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */
unsigned skip_vpd_pages:1; /* do not read VPD pages */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册