Commit 5c211caa authored by Alan Stern's avatar Alan Stern Committed by James Bottomley

[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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent b3f1f9aa
...@@ -1383,18 +1383,22 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer) ...@@ -1383,18 +1383,22 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
sd_read_protection_type(sdkp, buffer); sd_read_protection_type(sdkp, buffer);
} }
/* Some devices return the total number of sectors, not the /* Some devices are known to return the total number of blocks,
* highest sector number. Make the necessary adjustment. */ * not the highest block number. Some devices have versions
if (sdp->fix_capacity) { * 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; --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: got_data:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment