Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 136269
b: refs/heads/master
c: 5c211ca
h: refs/heads/master
i:
  136267: 57b2604
v: v3
  • Loading branch information
Alan Stern authored and James Bottomley committed Mar 12, 2009
1 parent 80e627c commit b6e303a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 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: b3f1f9aa082b2ab86dec4db3d8b1566af345387e
refs/heads/master: 5c211caa9f341f9eefbda89436d1440d1eccb3bc
26 changes: 15 additions & 11 deletions trunk/drivers/scsi/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,18 +1383,22 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
sd_read_protection_type(sdkp, buffer);
}

/* Some devices return the total number of sectors, not the
* highest sector number. Make the necessary adjustment. */
if (sdp->fix_capacity) {
/* Some devices are known to return the total number of blocks,
* not the highest block number. Some devices have versions
* which do this and others which do not. Some devices we might
* suspect of doing this but we don't know for certain.
*
* If we know the reported capacity is wrong, decrement it. If
* we can only guess, then assume the number of blocks is even
* (usually true but not always) and err on the side of lowering
* the capacity.
*/
if (sdp->fix_capacity ||
(sdp->guess_capacity && (sdkp->capacity & 0x01))) {
sd_printk(KERN_INFO, sdkp, "Adjusting the sector count "
"from its reported value: %llu\n",
(unsigned long long) sdkp->capacity);
--sdkp->capacity;

/* Some devices have version which report the correct sizes
* and others which do not. We guess size according to a heuristic
* and err on the side of lowering the capacity. */
} else {
if (sdp->guess_capacity)
if (sdkp->capacity & 0x01) /* odd sizes are odd */
--sdkp->capacity;
}

got_data:
Expand Down

0 comments on commit b6e303a

Please sign in to comment.