Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756127AbYHFOGw (ORCPT ); Wed, 6 Aug 2008 10:06:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753925AbYHFOGl (ORCPT ); Wed, 6 Aug 2008 10:06:41 -0400 Received: from extu-mxob-1.symantec.com ([216.10.194.28]:35121 "EHLO extu-mxob-1.symantec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753754AbYHFOGk (ORCPT ); Wed, 6 Aug 2008 10:06:40 -0400 Date: Wed, 6 Aug 2008 15:06:21 +0100 (BST) From: Hugh Dickins X-X-Sender: hugh@blonde.site To: James Bottomley cc: "Martin K. Petersen" , Andrew Morton , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][SCS] sd: Read Capacity if (16) fails Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1917 Lines: 49 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 --- 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; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/