diff options
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/sd.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 4970ae4a62d6..e744ee40be69 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -1383,18 +1383,22 @@ repeat: | |||
1383 | sd_read_protection_type(sdkp, buffer); | 1383 | sd_read_protection_type(sdkp, buffer); |
1384 | } | 1384 | } |
1385 | 1385 | ||
1386 | /* Some devices return the total number of sectors, not the | 1386 | /* Some devices are known to return the total number of blocks, |
1387 | * highest sector number. Make the necessary adjustment. */ | 1387 | * not the highest block number. Some devices have versions |
1388 | if (sdp->fix_capacity) { | 1388 | * which do this and others which do not. Some devices we might |
1389 | * suspect of doing this but we don't know for certain. | ||
1390 | * | ||
1391 | * If we know the reported capacity is wrong, decrement it. If | ||
1392 | * we can only guess, then assume the number of blocks is even | ||
1393 | * (usually true but not always) and err on the side of lowering | ||
1394 | * the capacity. | ||
1395 | */ | ||
1396 | if (sdp->fix_capacity || | ||
1397 | (sdp->guess_capacity && (sdkp->capacity & 0x01))) { | ||
1398 | sd_printk(KERN_INFO, sdkp, "Adjusting the sector count " | ||
1399 | "from its reported value: %llu\n", | ||
1400 | (unsigned long long) sdkp->capacity); | ||
1389 | --sdkp->capacity; | 1401 | --sdkp->capacity; |
1390 | |||
1391 | /* Some devices have version which report the correct sizes | ||
1392 | * and others which do not. We guess size according to a heuristic | ||
1393 | * and err on the side of lowering the capacity. */ | ||
1394 | } else { | ||
1395 | if (sdp->guess_capacity) | ||
1396 | if (sdkp->capacity & 0x01) /* odd sizes are odd */ | ||
1397 | --sdkp->capacity; | ||
1398 | } | 1402 | } |
1399 | 1403 | ||
1400 | got_data: | 1404 | got_data: |