Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 84405
b: refs/heads/master
c: 366c246
h: refs/heads/master
i:
  84403: 32f0bfb
v: v3
  • Loading branch information
James Bottomley authored and James Bottomley committed Feb 8, 2008
1 parent 2218126 commit ddb208a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 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: d7402cd91022fc32522397d3930a3e6587de7c55
refs/heads/master: 366c246de9cec909c5eba4f784c92d1e75b4dc38
34 changes: 16 additions & 18 deletions trunk/drivers/scsi/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ static int sd_done(struct scsi_cmnd *SCpnt)
unsigned int xfer_size = scsi_bufflen(SCpnt);
unsigned int good_bytes = result ? 0 : xfer_size;
u64 start_lba = SCpnt->request->sector;
u64 end_lba = SCpnt->request->sector + (xfer_size / 512);
u64 bad_lba;
struct scsi_sense_hdr sshdr;
int sense_valid = 0;
Expand Down Expand Up @@ -967,26 +968,23 @@ static int sd_done(struct scsi_cmnd *SCpnt)
goto out;
if (xfer_size <= SCpnt->device->sector_size)
goto out;
switch (SCpnt->device->sector_size) {
case 256:
if (SCpnt->device->sector_size < 512) {
/* only legitimate sector_size here is 256 */
start_lba <<= 1;
break;
case 512:
break;
case 1024:
start_lba >>= 1;
break;
case 2048:
start_lba >>= 2;
break;
case 4096:
start_lba >>= 3;
break;
default:
/* Print something here with limiting frequency. */
goto out;
break;
end_lba <<= 1;
} else {
/* be careful ... don't want any overflows */
u64 factor = SCpnt->device->sector_size / 512;
do_div(start_lba, factor);
do_div(end_lba, factor);
}

if (bad_lba < start_lba || bad_lba >= end_lba)
/* the bad lba was reported incorrectly, we have
* no idea where the error is
*/
goto out;

/* This computation should always be done in terms of
* the resolution of the device's medium.
*/
Expand Down

0 comments on commit ddb208a

Please sign in to comment.