When the SCSI device is initialized, check whether it supports WRITE_SAME_16 or WRITE_SAME_10 in the sd_read_write_same(). If the back-end storage device does not support queries, it will not set sdkp->ws16 as 1. When the WRITE_SAME io is issued through the blkdev_issue_write_same(), the WRITE_SAME type is set to WRITE_SAME_10 by default in the sd_setup_write_same_cmnd() since of "sdkp->ws16=0". If the storage device does not support WRITE_SAME_10, then the SCSI device is set to not support WRITE_SAME. Currently, some storage devices do not provide queries for WRITE_SAME_16 support, and only WRITE_SAME_16 is supported, not WRITE_SAME_10. Therefore, we need to provide a new flag for these storage devices. When initializing these devices, we will no longer query for support for WRITE_SAME_16 in the sd_read_write_same(), but set these SCSI disks to support WRITE_SAME_16 by default. In that way, we can add 'vendor:product:flag' to the module parameter 'dev_flags' for these storage devices. Signed-off-by: AlexChen <alex.chen@xxxxxxxxxx> --- drivers/scsi/sd.c | 4 +++- include/scsi/scsi_devinfo.h | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 4f7e7b607..a208ba5b5 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -68,6 +68,7 @@ #include <scsi/scsi_host.h> #include <scsi/scsi_ioctl.h> #include <scsi/scsicam.h> +#include <scsi/scsi_devinfo.h> #include "sd.h" #include "scsi_priv.h" @@ -3014,7 +3015,8 @@ static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer) sdev->no_write_same = 1; } - if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, WRITE_SAME_16) == 1) + if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, WRITE_SAME_16) == 1 || + sdev->sdev_bflags & BLIST_SUPPORT_WS16) sdkp->ws16 = 1; if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, WRITE_SAME) == 1) diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h index 3fdb322d4..da70d4795 100644 --- a/include/scsi/scsi_devinfo.h +++ b/include/scsi/scsi_devinfo.h @@ -67,8 +67,10 @@ #define BLIST_RETRY_ITF ((__force blist_flags_t)(1ULL << 32)) /* Always retry ABORTED_COMMAND with ASC 0xc1 */ #define BLIST_RETRY_ASC_C1 ((__force blist_flags_t)(1ULL << 33)) +/* support for write_same_16, no need to query */ +#define BLIST_SUPPORT_WS16 ((__force blist_flags_t)(1ULL << 34)) -#define __BLIST_LAST_USED BLIST_RETRY_ASC_C1 +#define __BLIST_LAST_USED BLIST_SUPPORT_WS16 #define __BLIST_HIGH_UNUSED (~(__BLIST_LAST_USED | \ (__force blist_flags_t) \ -- 2.19.1