The patch titled sd: tell the user when a disk's capacity is adjusted has been added to the -mm tree. Its filename is sd-tell-the-user-when-a-disks-capacity-is-adjusted.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: sd: tell the user when a disk's capacity is adjusted From: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxx> Cc: Jens Axboe <jens.axboe@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/scsi/sd.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff -puN drivers/scsi/sd.c~sd-tell-the-user-when-a-disks-capacity-is-adjusted drivers/scsi/sd.c --- a/drivers/scsi/sd.c~sd-tell-the-user-when-a-disks-capacity-is-adjusted +++ a/drivers/scsi/sd.c @@ -1386,18 +1386,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: _ Patches currently in -mm which might be from stern@xxxxxxxxxxxxxxxxxxx are linux-next.patch scsi-fix-proc-memory-leak-in-the-scsi-core.patch sd-tell-the-user-when-a-disks-capacity-is-adjusted.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html