[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 42/48] qemu-img: dynamically adjust iobuffer size dur
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 42/48] qemu-img: dynamically adjust iobuffer size during convert |
Date: |
Fri, 6 Dec 2013 17:36:41 +0100 |
From: Peter Lieven <address@hidden>
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.
Reviewed-by: Paolo Bonzini <address@hidden>
Signed-off-by: Peter Lieven <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
qemu-img.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 9fe0ede..0725f22 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1140,6 +1140,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;
@@ -1398,7 +1399,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);
@@ -1421,7 +1431,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;
@@ -1558,7 +1568,7 @@ static int img_convert(int argc, char **argv)
sector_num_next_status = sector_num + n1;
}
- n = MIN(nb_sectors, IO_BUF_SIZE / 512);
+ n = MIN(nb_sectors, bufsectors);
n = MIN(n, bs_sectors - (sector_num - bs_offset));
n1 = n;
--
1.8.4.2
- [Qemu-devel] [PULL 32/48] qemu-nbd: support internal snapshot export, (continued)
- [Qemu-devel] [PULL 32/48] qemu-nbd: support internal snapshot export, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 33/48] qemu-iotests: add 058 internal snapshot export with qemu-nbd case, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 34/48] qemu-img: add -l for snapshot in convert, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 35/48] qemu-iotests: add test for snapshot in qemu-img convert, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 36/48] qemu-nbd: add doc for option -f, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 37/48] qemu-img: add support for skipping zeroes in input during convert, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 38/48] qemu-img: fix usage instruction for qemu-img convert, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 39/48] block/iscsi: set bdi->cluster_size, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 40/48] block: add opt_transfer_length to BlockLimits, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 41/48] block/iscsi: set bs->bl.opt_transfer_length, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 42/48] qemu-img: dynamically adjust iobuffer size during convert,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 43/48] qemu-img: round down request length to an aligned sector, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 44/48] qemu-img: decrease progress update interval on convert, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 46/48] block: clean up bdrv_drain_all() throttling comments, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 47/48] aio: make aio_poll(ctx, true) block with no fds, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 48/48] qemu-iotests: filter QEMU monitor \r\n, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 45/48] qcow2: use start_of_cluster() and offset_into_cluster() everywhere, Stefan Hajnoczi, 2013/12/06
- [Qemu-devel] [PULL 31/48] snapshot: distinguish id and name in load_tmp, Stefan Hajnoczi, 2013/12/06