aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sd.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2009-02-18 10:54:44 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2009-03-12 13:58:15 -0400
commit5c211caa9f341f9eefbda89436d1440d1eccb3bc (patch)
tree4f7204ebacf152ea7057dce984c1db550dbce763 /drivers/scsi/sd.c
parentb3f1f9aa082b2ab86dec4db3d8b1566af345387e (diff)
[SCSI] sd: tell the user when a disk's capacity is adjusted
This patch (as1188) combines the tests for decrementing a drive's reported capacity and expands the comment. It also adds an informational message to the system log, informing the user when the reported value has been changed. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r--drivers/scsi/sd.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 4970ae4a62d..e744ee40be6 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
1400got_data: 1404got_data: