All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Eric Blake <eblake@redhat.com>, pbonzini@redhat.com
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, qemu-block@nongnu.org,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Max Reitz <mreitz@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 07/17] block: Give nonzero result to blk_get_max_transfer_length()
Date: Thu, 16 Jun 2016 13:25:02 +0800	[thread overview]
Message-ID: <20160616052502.GI12178@ad.usersys.redhat.com> (raw)
In-Reply-To: <1465939839-30097-8-git-send-email-eblake@redhat.com>

On Tue, 06/14 15:30, Eric Blake wrote:
> Making all callers special-case 0 as unlimited is awkward,
> and we DO have a hard maximum of BDRV_REQUEST_MAX_SECTORS given
> our current block layer API limits.
> 
> In the case of scsi, this means that we now always advertise a
> limit to the guest, even in cases where the underlying layers
> previously use 0 for no inherent limit beyond the block layer.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> 
> ---
> v2: new patch
> ---
>  block/block-backend.c  |  7 ++++---
>  hw/block/virtio-blk.c  |  3 +--
>  hw/scsi/scsi-generic.c | 12 ++++++------
>  3 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/block/block-backend.c b/block/block-backend.c
> index 34500e6..1fb070b 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -1303,15 +1303,16 @@ int blk_get_flags(BlockBackend *blk)
>      }
>  }
> 
> +/* Returns the maximum transfer length, in sectors; guaranteed nonzero */
>  int blk_get_max_transfer_length(BlockBackend *blk)
>  {
>      BlockDriverState *bs = blk_bs(blk);
> +    int max = 0;
> 
>      if (bs) {
> -        return bs->bl.max_transfer_length;
> -    } else {
> -        return 0;
> +        max = bs->bl.max_transfer_length;
>      }
> +    return MIN_NON_ZERO(max, BDRV_REQUEST_MAX_SECTORS);
>  }
> 
>  int blk_get_max_iov(BlockBackend *blk)
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 284e646..1d2792e 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -382,7 +382,7 @@ static int multireq_compare(const void *a, const void *b)
>  void virtio_blk_submit_multireq(BlockBackend *blk, MultiReqBuffer *mrb)
>  {
>      int i = 0, start = 0, num_reqs = 0, niov = 0, nb_sectors = 0;
> -    int max_xfer_len = 0;
> +    int max_xfer_len;
>      int64_t sector_num = 0;
> 
>      if (mrb->num_reqs == 1) {
> @@ -392,7 +392,6 @@ void virtio_blk_submit_multireq(BlockBackend *blk, MultiReqBuffer *mrb)
>      }
> 
>      max_xfer_len = blk_get_max_transfer_length(mrb->reqs[0]->dev->blk);
> -    max_xfer_len = MIN_NON_ZERO(max_xfer_len, BDRV_REQUEST_MAX_SECTORS);
> 
>      qsort(mrb->reqs, mrb->num_reqs, sizeof(*mrb->reqs),
>            &multireq_compare);
> diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
> index 71372a8..db04a76 100644
> --- a/hw/scsi/scsi-generic.c
> +++ b/hw/scsi/scsi-generic.c
> @@ -226,12 +226,12 @@ static void scsi_read_complete(void * opaque, int ret)
>          r->req.cmd.buf[0] == INQUIRY &&
>          r->req.cmd.buf[2] == 0xb0) {
>          uint32_t max_xfer_len = blk_get_max_transfer_length(s->conf.blk);
> -        if (max_xfer_len) {
> -            stl_be_p(&r->buf[8], max_xfer_len);
> -            /* Also take care of the opt xfer len. */
> -            if (ldl_be_p(&r->buf[12]) > max_xfer_len) {
> -                stl_be_p(&r->buf[12], max_xfer_len);
> -            }
> +
> +        assert(max_xfer_len);
> +        stl_be_p(&r->buf[8], max_xfer_len);
> +        /* Also take care of the opt xfer len. */
> +        if (ldl_be_p(&r->buf[12]) > max_xfer_len) {
> +            stl_be_p(&r->buf[12], max_xfer_len);

Paolo: should we take s->blocksize into account? I missed it when I wrote this
piece of code.

Fam

>          }
>      }
>      scsi_req_data(&r->req, len);
> -- 
> 2.5.5
> 
> 

  reply	other threads:[~2016-06-16  5:25 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-14 21:30 [Qemu-devel] [PATCH v2 00/17] Byte-based block limits Eric Blake
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 01/17] block: Tighter assertions on bdrv_aligned_pwritev() Eric Blake
2016-06-16  5:05   ` Fam Zheng
2016-06-20 12:09   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 02/17] block: Document supported flags during bdrv_aligned_preadv() Eric Blake
2016-06-16  5:08   ` Fam Zheng
2016-06-20 12:10   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 03/17] block: Fix harmless off-by-one in bdrv_aligned_preadv() Eric Blake
2016-06-16  5:10   ` Fam Zheng
2016-06-20 12:12   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 04/17] nbd: Allow larger requests Eric Blake
2016-06-15 13:37   ` Paolo Bonzini
2016-06-16  5:12   ` Fam Zheng
2016-06-20 12:13   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 05/17] nbd: Advertise realistic limits to block layer Eric Blake
2016-06-15 13:38   ` Paolo Bonzini
2016-06-22 20:58     ` Eric Blake
2016-06-16  5:13   ` Fam Zheng
2016-06-20 12:14   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 06/17] iscsi: " Eric Blake
2016-06-16  5:19   ` Fam Zheng
2016-06-20 12:16   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 07/17] block: Give nonzero result to blk_get_max_transfer_length() Eric Blake
2016-06-16  5:25   ` Fam Zheng [this message]
2016-06-16 13:22     ` Paolo Bonzini
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 08/17] blkdebug: Set request_alignment during .bdrv_refresh_limits() Eric Blake
2016-06-16  5:27   ` Fam Zheng
2016-06-21 13:27   ` Kevin Wolf
2016-06-21 22:17     ` Eric Blake
2016-06-22 10:05       ` Kevin Wolf
2016-06-22 17:33         ` Eric Blake
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 09/17] iscsi: " Eric Blake
2016-06-16  5:28   ` Fam Zheng
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 10/17] qcow2: " Eric Blake
2016-06-16  5:28   ` Fam Zheng
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 11/17] raw-win32: " Eric Blake
2016-06-16  5:30   ` Fam Zheng
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 12/17] block: " Eric Blake
2016-06-16  5:31   ` Fam Zheng
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 13/17] block: Set default request_alignment during bdrv_refresh_limits() Eric Blake
2016-06-16  5:32   ` Fam Zheng
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 14/17] block: Switch transfer length bounds to byte-based Eric Blake
2016-06-16  5:42   ` Fam Zheng
2016-06-21 13:50   ` Kevin Wolf
2016-06-21 22:20     ` Eric Blake
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 15/17] block: Switch discard " Eric Blake
2016-06-16  5:46   ` Fam Zheng
2016-06-16 14:21     ` Eric Blake
2016-06-17  2:28       ` Fam Zheng
2016-06-21 14:05   ` Kevin Wolf
2016-06-21 22:21     ` Eric Blake
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 16/17] block: Split bdrv_merge_limits() from bdrv_refresh_limits() Eric Blake
2016-06-16  5:50   ` Fam Zheng
2016-06-16 14:22     ` Eric Blake
2016-06-21 14:12   ` Kevin Wolf
2016-06-21 22:24     ` Eric Blake
2016-06-14 21:30 ` [Qemu-devel] [PATCH v2 17/17] block: Move request_alignment into BlockLimit Eric Blake
2016-06-16  5:52   ` Fam Zheng
2016-06-21 14:16   ` Kevin Wolf
2016-06-21 22:26     ` Eric Blake
2016-06-22 10:14       ` Kevin Wolf
2016-06-21 14:18 ` [Qemu-devel] [PATCH v2 00/17] Byte-based block limits Kevin Wolf
2016-06-21 22:27   ` Eric Blake

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=20160616052502.GI12178@ad.usersys.redhat.com \
    --to=famz@redhat.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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 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.