From: Ivan Mironov <mironov.ivan@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
"Martin K. Petersen" <martin.petersen@oracle.com>,
"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
Ivan Mironov <mironov.ivan@gmail.com>
Subject: [PATCH] scsi: sd: Fix cache_type_store()
Date: Sun, 23 Dec 2018 12:41:58 +0500 [thread overview]
Message-ID: <20181223074158.22796-1-mironov.ivan@gmail.com> (raw)
Changing of caching mode via /sys/devices/.../scsi_disk/.../cache_type
may fail if device responses to MODE SENSE command with DPOFUA flag set,
and then checks this flag to be not set on MODE SELECT command.
When trying to change cache_type, write always fails:
# echo "none" >cache_type
bash: echo: write error: Invalid argument
And following appears in dmesg:
[13007.865745] sd 1:0:1:0: [sda] Sense Key : Illegal Request [current]
[13007.865753] sd 1:0:1:0: [sda] Add. Sense: Invalid field in parameter list
Signed-off-by: Ivan Mironov <mironov.ivan@gmail.com>
---
drivers/scsi/sd.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index bd0a5c694a97..698fe651fb1a 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -206,6 +206,21 @@ cache_type_store(struct device *dev, struct device_attribute *attr,
sp = buffer_data[0] & 0x80 ? 1 : 0;
buffer_data[0] &= ~0x80;
+ /* From SBC-4 r15, 6.5.1 "Mode pages overview", description of
+ * DEVICE-SPECIFIC PARAMETER field in the mode parameter header:
+ * ...
+ * The write protect (WP) bit for mode data sent with a MODE SELECT
+ * command shall be ignored by the device server.
+ * ...
+ * The DPOFUA bit is reserved for mode data sent with a MODE SELECT
+ * command.
+ * ...
+ * All other bits are also reserved, and all reserved bits shall be set
+ * to zero according to the same document. So, we can simply set this
+ * field to zero for compatibility.
+ */
+ data.device_specific = 0;
+
if (scsi_mode_select(sdp, 1, sp, 8, buffer_data, len, SD_TIMEOUT,
SD_MAX_RETRIES, &data, &sshdr)) {
if (scsi_sense_valid(&sshdr))
--
2.20.1
next reply other threads:[~2018-12-23 7:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-23 7:41 Ivan Mironov [this message]
2019-01-04 4:37 ` [PATCH] scsi: sd: Fix cache_type_store() 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=20181223074158.22796-1-mironov.ivan@gmail.com \
--to=mironov.ivan@gmail.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.