aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2014-12-05 08:58:03 -0500
committerChristoph Hellwig <hch@lst.de>2014-12-30 07:30:38 -0500
commite461338b6cd4074e39a0d5fdd1dc5582fbca1520 (patch)
treefa0f9d67f5dc0e39a5bad80e80a18ac1d4eb9a86 /drivers/scsi
parentb7392d2247cfe6771f95d256374f1a8e6a6f48d6 (diff)
sd: tweak discard heuristics to work around QEMU SCSI issue
7985090aa020 changed the discard heuristics to give preference to the WRITE SAME commands that (unlike UNMAP) guarantee deterministic results. Ming Lei discovered that QEMU SCSI's WRITE SAME implementation internally relied on limits that were only communicated for the UNMAP case. And therefore discard commands backed by WRITE SAME would fail. Tweak the heuristics so we still pick UNMAP in the LBPRZ=0 case and only prefer the WRITE SAME variants if the device has the LBPRZ flag set. Reported-by: Ming Lei <ming.lei@canonical.com> Tested-by: Ming Lei <ming.lei@canonical.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/sd.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index fedab3c21ddf..399516925d80 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2623,8 +2623,9 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
2623 sd_config_discard(sdkp, SD_LBP_WS16); 2623 sd_config_discard(sdkp, SD_LBP_WS16);
2624 2624
2625 } else { /* LBP VPD page tells us what to use */ 2625 } else { /* LBP VPD page tells us what to use */
2626 2626 if (sdkp->lbpu && sdkp->max_unmap_blocks && !sdkp->lbprz)
2627 if (sdkp->lbpws) 2627 sd_config_discard(sdkp, SD_LBP_UNMAP);
2628 else if (sdkp->lbpws)
2628 sd_config_discard(sdkp, SD_LBP_WS16); 2629 sd_config_discard(sdkp, SD_LBP_WS16);
2629 else if (sdkp->lbpws10) 2630 else if (sdkp->lbpws10)
2630 sd_config_discard(sdkp, SD_LBP_WS10); 2631 sd_config_discard(sdkp, SD_LBP_WS10);