Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@canonical.com>
To: James Bottomley <JBottomley@parallels.com>,
	Christoph Hellwig <hch@lst.de>
Cc: linux-scsi@vger.kernel.org, Ming Lei <ming.lei@canonical.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [PATCH] SCSI: SD: set max_ws_blocks as max_unmap_blocks if it isn't provided
Date: Fri,  5 Dec 2014 20:35:51 +0800	[thread overview]
Message-ID: <1417782952-19908-1-git-send-email-ming.lei@canonical.com> (raw)

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


             reply	other threads:[~2014-12-05 12:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-05 12:35 Ming Lei [this message]
2014-12-05 12:56 ` [PATCH] SCSI: SD: set max_ws_blocks as max_unmap_blocks if it isn't provided 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1417782952-19908-1-git-send-email-ming.lei@canonical.com \
    --to=ming.lei@canonical.com \
    --cc=JBottomley@parallels.com \
    --cc=hch@lst.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox