[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 37/69] block/block-copy: limit copy_range_size to 16 MiB
From: |
Max Reitz |
Subject: |
[PULL 37/69] block/block-copy: limit copy_range_size to 16 MiB |
Date: |
Mon, 28 Oct 2019 13:14:29 +0100 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
Large copy range may imply memory allocation and large io effort, so
using 2G copy range request may be bad idea. Let's limit it to 16 MiB.
It also helps the following patch to refactor copy-with-offload
fallback to copy-with-bounce-buffer.
Note, that total memory usage of backup is still not limited, it will
be fixed in further commit.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Message-id: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
block/block-copy.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/block/block-copy.c b/block/block-copy.c
index ecd086010e..cd45b373a9 100644
--- a/block/block-copy.c
+++ b/block/block-copy.c
@@ -18,6 +18,9 @@
#include "qapi/error.h"
#include "block/block-copy.h"
#include "sysemu/block-backend.h"
+#include "qemu/units.h"
+
+#define BLOCK_COPY_MAX_COPY_RANGE (16 * MiB)
static void coroutine_fn block_copy_wait_inflight_reqs(BlockCopyState *s,
int64_t start,
@@ -70,9 +73,12 @@ BlockCopyState *block_copy_state_new(BdrvChild *source,
BdrvChild *target,
{
BlockCopyState *s;
BdrvDirtyBitmap *copy_bitmap;
+
+ /* Ignore BLOCK_COPY_MAX_COPY_RANGE if requested cluster_size is larger */
uint32_t max_transfer =
- MIN_NON_ZERO(INT_MAX, MIN_NON_ZERO(source->bs->bl.max_transfer,
- target->bs->bl.max_transfer));
+ MIN_NON_ZERO(MAX(cluster_size, BLOCK_COPY_MAX_COPY_RANGE),
+ MIN_NON_ZERO(source->bs->bl.max_transfer,
+ target->bs->bl.max_transfer));
copy_bitmap = bdrv_create_dirty_bitmap(source->bs, cluster_size, NULL,
errp);
--
2.21.0
- [PULL 27/69] iotests/201: Create socket in $SOCK_DIR, (continued)
- [PULL 27/69] iotests/201: Create socket in $SOCK_DIR, Max Reitz, 2019/10/28
- [PULL 26/69] iotests/194: Create sockets in $SOCK_DIR, Max Reitz, 2019/10/28
- [PULL 30/69] iotests/209: Create socket in $SOCK_DIR, Max Reitz, 2019/10/28
- [PULL 31/69] iotests/222: Create socket in $SOCK_DIR, Max Reitz, 2019/10/28
- [PULL 29/69] iotests/208: Create socket in $SOCK_DIR, Max Reitz, 2019/10/28
- [PULL 32/69] iotests/223: Create socket in $SOCK_DIR, Max Reitz, 2019/10/28
- [PULL 35/69] iotests: Drop TEST_DIR filter from _filter_nbd, Max Reitz, 2019/10/28
- [PULL 34/69] iotests/267: Create socket in $SOCK_DIR, Max Reitz, 2019/10/28
- [PULL 33/69] iotests/240: Create socket in $SOCK_DIR, Max Reitz, 2019/10/28
- [PULL 36/69] block/block-copy: allocate buffer in block_copy_with_bounce_buffer, Max Reitz, 2019/10/28
- [PULL 37/69] block/block-copy: limit copy_range_size to 16 MiB,
Max Reitz <=
- [PULL 38/69] block/block-copy: refactor copying, Max Reitz, 2019/10/28
- [PULL 39/69] util: introduce SharedResource, Max Reitz, 2019/10/28
- [PULL 40/69] block/block-copy: add memory limit, Max Reitz, 2019/10/28
- [PULL 41/69] block/block-copy: increase buffered copy request, Max Reitz, 2019/10/28
- [PULL 42/69] block/nvme: add support for write zeros, Max Reitz, 2019/10/28
- [PULL 43/69] block/nvme: add support for discard, Max Reitz, 2019/10/28
- [PULL 44/69] mirror: Do not dereference invalid pointers, Max Reitz, 2019/10/28
- [PULL 45/69] include: Move endof() up from hw/virtio/virtio.h, Max Reitz, 2019/10/28
- [PULL 46/69] qcow2: Use endof(), Max Reitz, 2019/10/28
- [PULL 49/69] qcow2: Make qcow2_write_snapshots() public, Max Reitz, 2019/10/28