diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2015-07-01 15:45:50 +0100 |
---|---|---|
committer | Jeff Cody <jcody@redhat.com> | 2015-08-06 04:41:09 -0400 |
commit | cae98cb87d269c33d23b2bccd79bb8d99a60d811 (patch) | |
tree | 0fd48543b2d8df826b152198ce27b03d9f1bb240 /block | |
parent | 2d697366a14ce95da2e9a59ea9872d3034eb49e4 (diff) | |
download | qemu-cae98cb87d269c33d23b2bccd79bb8d99a60d811.zip |
block/mirror: limit qiov to IOV_MAX elements
If mirror has more free buffers than IOV_MAX, preadv(2)/pwritev(2)
EINVAL failures may be encountered.
It is possible to trigger this by setting granularity to a low value
like 8192.
This patch stops appending chunks once IOV_MAX is reached.
The spurious EINVAL failure can be reproduced with a qcow2 image file
and the following QMP invocation:
qmp.command('drive-mirror', device='virtio0', target='/tmp/r7.s1',
granularity=8192, sync='full', mode='absolute-paths',
format='raw')
While the guest is running dd if=/dev/zero of=/var/tmp/foo oflag=direct
bs=4k.
Cc: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1435761950-26714-1-git-send-email-stefanha@redhat.com
Signed-off-by: Jeff Cody <jcody@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/mirror.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/block/mirror.c b/block/mirror.c index fc4d8f561e..0841964e97 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -245,6 +245,10 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) trace_mirror_break_buf_busy(s, nb_chunks, s->in_flight); break; } + if (IOV_MAX < nb_chunks + added_chunks) { + trace_mirror_break_iov_max(s, nb_chunks, added_chunks); + break; + } /* We have enough free space to copy these sectors. */ bitmap_set(s->in_flight_bitmap, next_chunk, added_chunks); |