mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][SCS] sd: Read Capacity if (16) fails
Date: Wed, 6 Aug 2008 15:06:21 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0808061500450.1109@blonde.site> (raw)

Commit e0597d70012c82e16ee152270a55d89d8bf66693 (sd: Identify DIF protection
type and application tag ownership) says that if a disk is formatted with
Inquiry bit PROTECT=1, it is required to support Read Capacity(16).  But my
SD cards, accessed by builtin cardreader and generic USB storage, disagree.

Therefore fall back to the familiar Read Capacity if Read Capacity(16) fails:
without even showing the "failed" message since I expect this will be common.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
---
Or is USB storage missing something to support Read Capacity(16)?

 drivers/scsi/sd.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- 2.6.27-rc2/drivers/scsi/sd.c	2008-07-29 04:24:38.000000000 +0100
+++ linux/drivers/scsi/sd.c	2008-08-06 08:53:13.000000000 +0100
@@ -1287,6 +1287,7 @@ sd_read_capacity(struct scsi_disk *sdkp,
 	int sector_size = 0;
 	/* Force READ CAPACITY(16) when PROTECT=1 */
 	int longrc = scsi_device_protection(sdkp->device) ? 1 : 0;
+	int tried_both = 0;
 	struct scsi_sense_hdr sshdr;
 	int sense_valid = 0;
 	struct scsi_device *sdp = sdkp->device;
@@ -1341,6 +1342,10 @@ repeat:
 		return;
 	} else if (the_result && longrc) {
 		/* READ CAPACITY(16) has been failed */
+		if (!tried_both++) {
+			longrc = 0;
+			goto repeat;
+		}
 		sd_printk(KERN_NOTICE, sdkp, "READ CAPACITY(16) failed\n");
 		sd_print_result(sdkp, the_result);
 		sd_printk(KERN_NOTICE, sdkp, "Use 0xffffffff as device size\n");
@@ -1357,6 +1362,7 @@ repeat:
 			if(sizeof(sdkp->capacity) > 4) {
 				sd_printk(KERN_NOTICE, sdkp, "Very big device. "
 					  "Trying to use READ CAPACITY(16).\n");
+				tried_both++;
 				longrc = 1;
 				goto repeat;
 			}

             reply	other threads:[~2008-08-06 14:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-06 14:06 Hugh Dickins [this message]
2008-08-06 14:25 ` Matthew Wilcox
2008-08-06 16:35   ` James Bottomley
2008-08-06 14:27 ` Martin K. Petersen
2008-08-06 15:34   ` Hugh Dickins
2008-08-06 16:36     ` James Bottomley
2008-08-06 16:44       ` Martin K. Petersen
2008-08-06 16:53       ` James Bottomley
2008-08-06 17:21         ` Hugh Dickins
2008-08-06 17:32           ` Martin K. Petersen
2008-08-06 17:36             ` James Bottomley
2008-08-06 16:44     ` Douglas Gilbert

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=Pine.LNX.4.64.0808061500450.1109@blonde.site \
    --to=hugh@veritas.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=akpm@linux-foundation.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®