Commit e461338b6cd4074e39a0d5fdd1dc5582fbca1520
Committed by
Christoph Hellwig
1 parent
b7392d2247
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
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>
Showing 1 changed file with 3 additions and 2 deletions Side-by-side Diff
drivers/scsi/sd.c
... | ... | @@ -2623,8 +2623,9 @@ |
2623 | 2623 | sd_config_discard(sdkp, SD_LBP_WS16); |
2624 | 2624 | |
2625 | 2625 | } else { /* LBP VPD page tells us what to use */ |
2626 | - | |
2627 | - if (sdkp->lbpws) | |
2626 | + if (sdkp->lbpu && sdkp->max_unmap_blocks && !sdkp->lbprz) | |
2627 | + sd_config_discard(sdkp, SD_LBP_UNMAP); | |
2628 | + else if (sdkp->lbpws) | |
2628 | 2629 | sd_config_discard(sdkp, SD_LBP_WS16); |
2629 | 2630 | else if (sdkp->lbpws10) |
2630 | 2631 | sd_config_discard(sdkp, SD_LBP_WS10); |