OSDN Git Service

sd: Make discard granularity match logical block size when LBPRZ=1
authorMartin K. Petersen <martin.petersen@oracle.com>
Fri, 13 Nov 2015 21:46:47 +0000 (16:46 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 26 Nov 2015 02:38:34 +0000 (21:38 -0500)
commit397737223c59e89dca7305feb6528caef8fbef84
treecce407c1cc11362e59bc1389ad30fe4d1de2cbea
parent653cfb85fbe73be44fda14bb67f1b95818bfc37f
sd: Make discard granularity match logical block size when LBPRZ=1

A device may report an OPTIMAL UNMAP GRANULARITY and UNMAP GRANULARITY
ALIGNMENT in the Block Limits VPD. These parameters describe the
device's internal provisioning allocation units. By default the block
layer will round and align any discard requests based on these limits.

If a device reports LBPRZ=1 to guarantee zeroes after discard, however,
it is imperative that the block layer does not leave out any parts of
the requested block range. Otherwise the device can not do the required
zeroing of any partial allocation units and this can lead to data
corruption.

Since the dm thinp personality relies on the block layer's current
behavior and is unable to deal with partial discard blocks we work
around the problem by setting the granularity to match the logical block
size when LBPRZ is enabled.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/sd.c