linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: AlexChen <alex.chen@huawei.com>
To: <jejb@linux.ibm.com>, <martin.petersen@oracle.com>
Cc: <linux-scsi@vger.kernel.org>, <zhengchuan@huawei.com>,
	<jiangyiwen@huawei.com>, <robin.yb@huawei.com>
Subject: [PATCH] scsi: sd: provide a new module parameter to set whether SCSI disks support WRITE_SAME_16 by default
Date: Sun, 19 Jan 2020 22:13:39 +0800	[thread overview]
Message-ID: <5E246413.8010408@huawei.com> (raw)

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/WRITE_SAME_10 support, but they do support WRITE_SAME_16 and
do not support WRITE_SAME_10. So in order for these devices to use
WRITE_SAME, we need a new module parameter to set whether SCSI disks
support WRITE_SAME_16 by default.

Signed-off-by: AlexChen <alex.chen@huawei.com>
---
 drivers/scsi/sd.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 4f7e7b607..ff368701d 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -104,6 +104,9 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_ZBC);
 #define SD_MINORS	0
 #endif

+static int sd_default_support_ws16;
+module_param(sd_default_support_ws16, int, 0644);
+
 static void sd_config_discard(struct scsi_disk *, unsigned int);
 static void sd_config_write_same(struct scsi_disk *);
 static int  sd_revalidate_disk(struct gendisk *);
@@ -3014,7 +3017,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 ||
+			sd_default_support_ws16)
 		sdkp->ws16 = 1;

 	if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, WRITE_SAME) == 1)
-- 2.19.1


             reply	other threads:[~2020-01-19 14:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-19 14:13 AlexChen [this message]
2020-01-19 19:36 ` [PATCH] scsi: sd: provide a new module parameter to set whether SCSI disks support WRITE_SAME_16 by default Bart Van Assche
2020-01-20  7:32   ` AlexChen
2020-01-21  0:01   ` Martin K. Petersen

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=5E246413.8010408@huawei.com \
    --to=alex.chen@huawei.com \
    --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).