qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Lieven <pl@kamp.de>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCHv2 1.8 6/9] qemu-img: dynamically adjust iobuffer size during convert
Date: Tue, 26 Nov 2013 10:48:25 +0100	[thread overview]
Message-ID: <52946E69.9090708@redhat.com> (raw)
In-Reply-To: <1385456183-24840-7-git-send-email-pl@kamp.de>

Il 26/11/2013 09:56, Peter Lieven ha scritto:
> since the convert process is basically a sync operation it might
> be benificial in some case to change the hardcoded I/O buffer
> size to a greater value.
> 
> This patch increases the I/O buffer size if the output
> driver advertises an optimal transfer length or discard alignment
> that is greater than the default buffer size of 2M.
> 
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
>  qemu-img.c |   18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/qemu-img.c b/qemu-img.c
> index e2d1a0a..b076d44 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -1135,6 +1135,7 @@ static int img_convert(int argc, char **argv)
>              sector_num_next_status = 0;
>      uint64_t bs_sectors;
>      uint8_t * buf = NULL;
> +    size_t bufsectors = IO_BUF_SIZE / BDRV_SECTOR_SIZE;
>      const uint8_t *buf1;
>      BlockDriverInfo bdi;
>      QEMUOptionParameter *param = NULL, *create_options = NULL;
> @@ -1371,7 +1372,16 @@ static int img_convert(int argc, char **argv)
>      bs_i = 0;
>      bs_offset = 0;
>      bdrv_get_geometry(bs[0], &bs_sectors);
> -    buf = qemu_blockalign(out_bs, IO_BUF_SIZE);
> +
> +    /* increase bufsectors from the default 4096 (2M) if opt_transfer_length
> +     * or discard_alignment of the out_bs is greater. Limit to 32768 (16MB)
> +     * as maximum. */
> +    bufsectors = MIN(32768,
> +                     MAX(bufsectors, MAX(out_bs->bl.opt_transfer_length,
> +                                         out_bs->bl.discard_alignment))
> +                    );
> +
> +    buf = qemu_blockalign(out_bs, bufsectors * BDRV_SECTOR_SIZE);
>  
>      if (skip_create) {
>          int64_t output_length = bdrv_getlength(out_bs);
> @@ -1394,7 +1404,7 @@ static int img_convert(int argc, char **argv)
>              goto out;
>          }
>          cluster_size = bdi.cluster_size;
> -        if (cluster_size <= 0 || cluster_size > IO_BUF_SIZE) {
> +        if (cluster_size <= 0 || cluster_size > bufsectors * BDRV_SECTOR_SIZE) {
>              error_report("invalid cluster size");
>              ret = -1;
>              goto out;
> @@ -1531,8 +1541,8 @@ static int img_convert(int argc, char **argv)
>                  sector_num_next_status = sector_num + n1;
>              }
>  
> -            if (nb_sectors >= (IO_BUF_SIZE / 512)) {
> -                n = (IO_BUF_SIZE / 512);
> +            if (nb_sectors >= bufsectors) {
> +                n = bufsectors;
>              } else {
>                  n = nb_sectors;
>              }
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

  reply	other threads:[~2013-11-26  9:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-26  8:56 [Qemu-devel] [PATCHv2 1.8 0/9] qemu-img convert optimizations Peter Lieven
2013-11-26  8:56 ` [Qemu-devel] [PATCHv2 1.8 1/9] qemu-img: add support for skipping zeroes in input during convert Peter Lieven
2013-11-26 10:02   ` Paolo Bonzini
2013-11-26 13:40     ` Peter Lieven
2013-11-26  8:56 ` [Qemu-devel] [PATCHv2 1.8 2/9] qemu-img: fix usage instruction for qemu-img convert Peter Lieven
2013-11-26  9:46   ` Paolo Bonzini
2013-11-26  8:56 ` [Qemu-devel] [PATCHv2 1.8 3/9] block/iscsi: set bdi->cluster_size Peter Lieven
2013-11-26  8:56 ` [Qemu-devel] [PATCHv2 1.8 4/9] block: add opt_transfer_length to BlockLimits Peter Lieven
2013-11-26  9:47   ` Paolo Bonzini
2013-11-26  8:56 ` [Qemu-devel] [PATCHv2 1.8 5/9] block/iscsi: set bs->bl.opt_transfer_length Peter Lieven
2013-11-26  9:47   ` Paolo Bonzini
2013-11-26  8:56 ` [Qemu-devel] [PATCHv2 1.8 6/9] qemu-img: dynamically adjust iobuffer size during convert Peter Lieven
2013-11-26  9:48   ` Paolo Bonzini [this message]
2013-11-26  8:56 ` [Qemu-devel] [PATCHv2 1.8 7/9] qemu-img: round down request length to an aligned sector Peter Lieven
2013-11-26  9:51   ` Paolo Bonzini
2013-11-26  8:56 ` [Qemu-devel] [PATCHv2 1.8 8/9] qemu-img: add option to show progress in sectors Peter Lieven
2013-11-26 10:04   ` Paolo Bonzini
2013-11-26 12:23     ` Peter Lieven
2013-11-26 12:40       ` Paolo Bonzini
2013-11-26  8:56 ` [Qemu-devel] [PATCHv2 1.8 9/9] qemu-img: increase min_sparse to 128 sectors (64kb) Peter Lieven
2013-11-26  9:51   ` Paolo Bonzini

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=52946E69.9090708@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pl@kamp.de \
    --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 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).