Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 136329
b: refs/heads/master
c: 2b30130
h: refs/heads/master
i:
  136327: a7e401b
v: v3
  • Loading branch information
Matthew Wilcox authored and James Bottomley committed Mar 18, 2009
1 parent 42c500b commit 4d664ff
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0da205e01bc58cfad660659e3c901223d3596c57
refs/heads/master: 2b301307f63dbecf06d91f58f003c7fb7addee24
27 changes: 24 additions & 3 deletions trunk/drivers/scsi/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1329,8 +1329,17 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
if (media_not_present(sdkp, &sshdr))
return -ENODEV;

if (the_result)
if (the_result) {
sense_valid = scsi_sense_valid(&sshdr);
if (sense_valid &&
sshdr.sense_key == ILLEGAL_REQUEST &&
(sshdr.asc == 0x20 || sshdr.asc == 0x24) &&
sshdr.ascq == 0x00)
/* Invalid Command Operation Code or
* Invalid Field in CDB, just retry
* silently with RC10 */
return -EINVAL;
}
retries--;

} while (the_result && retries);
Expand Down Expand Up @@ -1414,6 +1423,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
*/
Expand All @@ -1423,11 +1441,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 {
Expand Down

0 comments on commit 4d664ff

Please sign in to comment.