sd: Fix excessive capacity printing on devices with blocks bigger than 512 bytes
authorMartin K. Petersen <martin.petersen@oracle.com>
Tue, 29 Mar 2016 01:18:56 +0000 (21:18 -0400)
committerSasha Levin <sasha.levin@oracle.com>
Wed, 20 Apr 2016 05:03:43 +0000 (01:03 -0400)
commit9dcc54b46e2c231877dfdf28f883789925985891
tree0c6561f40dd510d093f9c33c78069bdce2986919
parent6175a5af31d191c3b866820fe875ff30b9222dd3
sd: Fix excessive capacity printing on devices with blocks bigger than 512 bytes

[ Upstream commit f08bb1e0dbdd0297258d0b8cd4dbfcc057e57b2a ]

During revalidate we check whether device capacity has changed before we
decide whether to output disk information or not.

The check for old capacity failed to take into account that we scaled
sdkp->capacity based on the reported logical block size. And therefore
the capacity test would always fail for devices with sectors bigger than
512 bytes and we would print several copies of the same discovery
information.

Avoid scaling sdkp->capacity and instead adjust the value on the fly
when setting the block device capacity and generating fake C/H/S
geometry.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Cc: <stable@vger.kernel.org>
Reported-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Hannes Reinicke <hare@suse.de>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
drivers/scsi/sd.c
drivers/scsi/sd.h