From: AlexChen <alex.chen@huawei.com>
To: <jejb@linux.ibm.com>, <martin.petersen@oracle.com>,
Bart Van Assche <bvanassche@acm.org>
Cc: <linux-scsi@vger.kernel.org>, <zhengchuan@huawei.com>,
<jiangyiwen@huawei.com>, <robin.yb@huawei.com>
Subject: [PATCH V2] scsi: add a new flag to set whether SCSI disks support WRITE_SAME_16 by default
Date: Sat, 1 Feb 2020 14:54:31 +0800 [thread overview]
Message-ID: <5E3520A7.5030501@huawei.com> (raw)
In-Reply-To: <5E28118F.3070706@huawei.com>
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@huawei.com>
---
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
next parent reply other threads:[~2020-02-01 6:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5E28118F.3070706@huawei.com>
2020-02-01 6:54 ` AlexChen [this message]
2020-02-05 2:30 ` [PATCH V2] scsi: add a new flag to set whether SCSI disks support WRITE_SAME_16 by default Martin K. Petersen
2020-02-07 8:51 ` AlexChen
2020-02-25 3:53 ` AlexChen
2020-02-25 18:31 ` Christoph Hellwig
2020-02-26 11:50 ` AlexChen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5E3520A7.5030501@huawei.com \
--to=alex.chen@huawei.com \
--cc=bvanassche@acm.org \
--cc=jejb@linux.ibm.com \
--cc=jiangyiwen@huawei.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=robin.yb@huawei.com \
--cc=zhengchuan@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).