From: Paolo Bonzini <pbonzini@redhat.com>
To: "Martin K. Petersen" <martin.petersen@oracle.com>,
Ming Lei <ming.lei@canonical.com>
Cc: James Bottomley <JBottomley@parallels.com>,
Christoph Hellwig <hch@lst.de>,
Linux SCSI List <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] SCSI: SD: set max_ws_blocks as max_unmap_blocks if it isn't provided
Date: Fri, 05 Dec 2014 16:43:50 +0100 [thread overview]
Message-ID: <5481D2B6.2050104@redhat.com> (raw)
In-Reply-To: <yq1egsefbbo.fsf@sermon.lab.mkp.net>
On 05/12/2014 14:58, Martin K. Petersen wrote:
>>>>>> "Ming" == Ming Lei <ming.lei@canonical.com> writes:
>
>>> What about in READ CAPACITY(16)?
>
> Ming> It isn't set too.
>
> Please try the following patch:
>
>
> [SCSI] 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>
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
>
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 95bfb7bfbb9d..76c5d1388417 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)
> sd_config_discard(sdkp, SD_LBP_WS16);
>
> } else { /* LBP VPD page tells us what to use */
> -
> - if (sdkp->lbpws)
> + if (sdkp->lbpu && sdkp->max_unmap_blocks && !sdkp->lbprz)
> + sd_config_discard(sdkp, SD_LBP_UNMAP);
> + else if (sdkp->lbpws)
> sd_config_discard(sdkp, SD_LBP_WS16);
> else if (sdkp->lbpws10)
> sd_config_discard(sdkp, SD_LBP_WS10);
>
This is the right fix. Ming, how do you reproduce the QEMU bug?
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2014-12-05 15:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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=5481D2B6.2050104@redhat.com \
--to=pbonzini@redhat.com \
--cc=JBottomley@parallels.com \
--cc=hch@lst.de \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=ming.lei@canonical.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