summaryrefslogtreecommitdiff
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 12:58:15 -0500
commit5c211caa9f341f9eefbda89436d1440d1eccb3bc (patch)
tree4f7204ebacf152ea7057dce984c1db550dbce763 /drivers/scsi/sd.c
parentb3f1f9aa082b2ab86dec4db3d8b1566af345387e (diff)
downloadlwn-5c211caa9f341f9eefbda89436d1440d1eccb3bc.tar.gz
lwn-5c211caa9f341f9eefbda89436d1440d1eccb3bc.zip
[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 4970ae4a62d6..e744ee40be69 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1383,18 +1383,22 @@ repeat:
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: