qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v6 07/20] scsi-disk: Switch to byte-based aio block access
Date: Fri, 6 May 2016 14:50:41 +0200	[thread overview]
Message-ID: <20160506125041.GF5093@noname.redhat.com> (raw)
In-Reply-To: <1462406126-22946-8-git-send-email-eblake@redhat.com>

Am 05.05.2016 um 01:55 hat Eric Blake geschrieben:
> Sector-based blk_aio_readv() and blk_aio_writev() should die; switch
> to byte-based blk_aio_preadv() and blk_aio_pwritev() instead.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  hw/scsi/scsi-disk.c | 31 +++++++++++++++----------------
>  1 file changed, 15 insertions(+), 16 deletions(-)
> 
> diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
> index 1335392..5d98f7b 100644
> --- a/hw/scsi/scsi-disk.c
> +++ b/hw/scsi/scsi-disk.c
> @@ -343,8 +343,9 @@ static void scsi_do_read(SCSIDiskReq *r, int ret)
>          n = scsi_init_iovec(r, SCSI_DMA_BUF_SIZE);
>          block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct,
>                           n * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);

If you replace n * BDRV_SECTOR_SIZE here as well, n is unused and can go
away (you actually did that already for writes).

> -        r->req.aiocb = blk_aio_readv(s->qdev.conf.blk, r->sector, &r->qiov, n,
> -                                     scsi_read_complete, r);
> +        r->req.aiocb = blk_aio_preadv(s->qdev.conf.blk,
> +                                      r->sector << BDRV_SECTOR_BITS, &r->qiov,
> +                                      0, scsi_read_complete, r);
>      }
> 
>  done:
> @@ -504,7 +505,6 @@ static void scsi_write_data(SCSIRequest *req)
>  {
>      SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
>      SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
> -    uint32_t n;
> 
>      /* No data transfer may already be in progress */
>      assert(r->req.aiocb == NULL);
> @@ -544,11 +544,11 @@ static void scsi_write_data(SCSIRequest *req)
>          r->req.aiocb = dma_blk_write(s->qdev.conf.blk, r->req.sg, r->sector,
>                                       scsi_dma_complete, r);
>      } else {
> -        n = r->qiov.size / 512;
>          block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct,
> -                         n * BDRV_SECTOR_SIZE, BLOCK_ACCT_WRITE);
> -        r->req.aiocb = blk_aio_writev(s->qdev.conf.blk, r->sector, &r->qiov, n,
> -                                      scsi_write_complete, r);
> +                         r->qiov.size, BLOCK_ACCT_WRITE);
> +        r->req.aiocb = blk_aio_pwritev(s->qdev.conf.blk,
> +                                       r->sector << BDRV_SECTOR_BITS, &r->qiov,
> +                                       0, scsi_write_complete, r);
>      }
>  }
> 
> @@ -1730,13 +1730,11 @@ static void scsi_write_same_complete(void *opaque, int ret)
>      if (data->iov.iov_len) {
>          block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct,
>                           data->iov.iov_len, BLOCK_ACCT_WRITE);
> -        /* blk_aio_write doesn't like the qiov size being different from
> -         * nb_sectors, make sure they match.
> -         */

Wouldn't it be better to update the comment instead of deleting it? If I
understand correctly, this additional qemu_iovec_init_external() is for
the last part of an unaligned WRITE SAME request, where the qiov can
become shorter than in the previous iterations.

>          qemu_iovec_init_external(&data->qiov, &data->iov, 1);
> -        r->req.aiocb = blk_aio_writev(s->qdev.conf.blk, data->sector,
> -                                      &data->qiov, data->iov.iov_len / 512,
> -                                      scsi_write_same_complete, data);
> +        r->req.aiocb = blk_aio_pwritev(s->qdev.conf.blk,
> +                                       data->sector << BDRV_SECTOR_BITS,
> +                                       &data->qiov, 0,
> +                                       scsi_write_same_complete, data);
>          return;
>      }

Kevin

  reply	other threads:[~2016-05-06 12:51 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-04 23:55 [Qemu-devel] [PATCH v6 00/20] block: kill sector-based blk_write/read Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 01/20] block: Allow BDRV_REQ_FUA through blk_pwrite() Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 02/20] block: Drop private ioctl-only members of BlockRequest Eric Blake
2016-05-06 10:37   ` Kevin Wolf
2016-05-06 12:23     ` Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 03/20] block: Switch blk_read_unthrottled() to byte interface Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 04/20] block: Switch blk_*write_zeroes() " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 05/20] block: Introduce byte-based aio read/write Eric Blake
2016-05-06 12:31   ` Kevin Wolf
2016-05-06 14:12     ` Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 06/20] ide: Switch to byte-based aio block access Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 07/20] scsi-disk: " Eric Blake
2016-05-06 12:50   ` Kevin Wolf [this message]
2016-05-06 14:18     ` Eric Blake
2016-05-06 14:49       ` Kevin Wolf
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 08/20] virtio: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 09/20] xen_disk: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 10/20] fdc: Switch to byte-based " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 11/20] nand: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 12/20] onenand: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 13/20] pflash: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 14/20] sd: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 15/20] m25p80: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 16/20] atapi: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 17/20] nbd: " Eric Blake
2016-05-06 13:08   ` Kevin Wolf
2016-05-06 14:19     ` Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 18/20] qemu-img: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 19/20] qemu-io: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 20/20] block: Kill unused sector-based blk_* functions Eric Blake
2016-05-06 13:11 ` [Qemu-devel] [PATCH v6 00/20] block: kill sector-based blk_write/read Kevin Wolf
2016-05-06 14:20   ` 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=20160506125041.GF5093@noname.redhat.com \
    --to=kwolf@redhat.com \
    --cc=eblake@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).