From: Matthew Wilcox <willy@linux.intel.com>
To: James.Bottomley@HansenPartnership.com
Cc: linux-scsi@vger.kernel.org, Matthew Wilcox <matthew@wil.cx>,
Matthew Wilcox <willy@linux.intel.com>
Subject: [PATCH 2/2] sd: Try READ CAPACITY 16 first for SBC-2 devices
Date: Thu, 12 Mar 2009 14:20:30 -0400 [thread overview]
Message-ID: <1236882030-27964-3-git-send-email-willy@linux.intel.com> (raw)
In-Reply-To: <1236882030-27964-1-git-send-email-willy@linux.intel.com>
From: Matthew Wilcox <matthew@wil.cx>
New features are being added to the READ CAPACITY 16 results, so we
want to issue it in preference to READ CAPACITY 10. Unfortunately, some
devices misbehave when they see a READ CAPACITY 16, so we restrict this
command to devices which claim conformance to SPC-3 (aka SBC-2), or claim
they have features which are only reported in the READ CAPACITY 16 data.
The READ CAPACITY 16 command is optional, even for SBC-2 devices, so
we fall back to READ CAPACITY 10 if READ CAPACITY 16 fails.
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Tested-by: Martin K. Petersen <martin.petersen@oracle.com>
---
drivers/scsi/sd.c | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 6cf0c25..b155488 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1418,6 +1418,15 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
return sector_size;
}
+static int sd_try_rc16_first(struct scsi_device *sdp)
+{
+ if (sdp->scsi_level > SCSI_SPC_2)
+ return 1;
+ if (scsi_device_protection(sdp))
+ return 1;
+ return 0;
+}
+
/*
* read disk capacity
*/
@@ -1427,11 +1436,14 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
int sector_size;
struct scsi_device *sdp = sdkp->device;
- /* Force READ CAPACITY(16) when PROTECT=1 */
- if (scsi_device_protection(sdp)) {
+ if (sd_try_rc16_first(sdp)) {
sector_size = read_capacity_16(sdkp, sdp, buffer);
if (sector_size == -EOVERFLOW)
goto got_data;
+ if (sector_size == -ENODEV)
+ return;
+ if (sector_size < 0)
+ sector_size = read_capacity_10(sdkp, sdp, buffer);
if (sector_size < 0)
return;
} else {
--
1.6.1.3
next prev parent reply other threads:[~2009-03-12 18:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-12 18:20 Support READ CAPACITY 16 on more drives Matthew Wilcox
2009-03-12 18:20 ` [PATCH 1/2] sd: Refactor sd_read_capacity() Matthew Wilcox
2009-03-12 18:35 ` Martin K. Petersen
2009-03-13 21:29 ` James Bottomley
2009-03-13 21:45 ` Martin K. Petersen
2009-03-14 1:19 ` Matthew Wilcox
2009-03-14 13:40 ` James Bottomley
2009-03-12 18:20 ` Matthew Wilcox [this message]
2009-03-14 20:41 ` [PATCH 2/2] sd: Try READ CAPACITY 16 first for SBC-2 devices James Bottomley
2009-03-14 22:48 ` Matthew Wilcox
2009-03-14 23:34 ` James Bottomley
2009-03-14 23:47 ` Matthew Wilcox
2009-03-15 2:36 ` Douglas Gilbert
2009-03-15 3:30 ` James Bottomley
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=1236882030-27964-3-git-send-email-willy@linux.intel.com \
--to=willy@linux.intel.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=linux-scsi@vger.kernel.org \
--cc=matthew@wil.cx \
/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