All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] SCSI: SD: set max_ws_blocks as max_unmap_blocks if it isn't provided
@ 2014-12-05 12:35 Ming Lei
  2014-12-05 12:56 ` Martin K. Petersen
  0 siblings, 1 reply; 13+ messages in thread
From: Ming Lei @ 2014-12-05 12:35 UTC (permalink / raw)
  To: James Bottomley, Christoph Hellwig
  Cc: linux-scsi, Ming Lei, Martin K. Petersen, Paolo Bonzini

The commit 7985090aa0201(sd: Disable discard_zeroes_data for UNMAP)
introduces regresion for QEMU SCSI.

QEMU SCSI device claims to support UNMAP, WRITE SAME and WRITE SAME
16 in LBP VPD page, but only provides "Maximum unmap LBA count"
in block limits VPD page, and "Maximum write same length" isn't set.

The default max_discard_sectors(SD_MAX_WS16_BLOCKS) can't work at
all since it is much bigger than the actual Maximum unmap LBA count.

This patch trys to fix the regression by setting 'max_ws_blocks'
as 'max_unmap_blocks' when block limits VPD page doesn't provide
"Maximum write same length" under the situation. This approach is
reasonable because device server supports the use of the WRITE
SAME or WRITE SAME 10 command to unmap LBAs when LBPWS or LBPWS10
is set in LBP VPD page.

Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 drivers/scsi/sd.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index fedab3c..2a69fee 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2624,6 +2624,14 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
 
 		} else {	/* LBP VPD page tells us what to use */
 
+			/*
+			 * Borrow max_unmap_blocks if max_ws_blocks isn't
+			 * provided from block limits VPD page
+			 */
+			if ((sdkp->lbpws10 || sdkp->lbpws) &&
+			    !sdkp->max_ws_blocks)
+				sdkp->max_ws_blocks = sdkp->max_unmap_blocks;
+
 			if (sdkp->lbpws)
 				sd_config_discard(sdkp, SD_LBP_WS16);
 			else if (sdkp->lbpws10)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-12-30 12:51 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-05 12:35 [PATCH] SCSI: SD: set max_ws_blocks as max_unmap_blocks if it isn't provided Ming Lei
2014-12-05 12:56 ` Martin K. Petersen
2014-12-05 13:05   ` Ming Lei
2014-12-05 13:22     ` Martin K. Petersen
2014-12-05 13:37       ` Ming Lei
2014-12-05 13:38         ` Martin K. Petersen
2014-12-05 13:47           ` Ming Lei
2014-12-05 13:58             ` Martin K. Petersen
2014-12-05 14:19               ` Ming Lei
2014-12-05 15:43               ` Paolo Bonzini
2014-12-30 12:51               ` Christoph Hellwig
2014-12-05 15:49     ` Paolo Bonzini
2014-12-05 16:21       ` Ming Lei

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.