block: avoid creating too large iovecs in multiwrite_merge
PATCH v2 1/1 block: avoid creating too large iovecs in multiwrite_merge
If we go over the maximum number of iovecs support by syscall we get back EINVAL from the kernel which translate to I/O errors for the guest.
Add a MAX_IOV defintion for platforms that don't have it. For now we use the same 1024 define that's used on Linux and various other platforms, but until the windows block backend implements some kind of vectored I/O it doesn't matter.
block.c +4 -0
@@ -1689,6 +1689,10 @@ static int multiwrite_merge(BlockDriverS merge = bs->drv->bdrv_merge_requests (bs, &reqs[outidx], &reqs[i]); } +if (reqs[outidx].qiov->niov + reqs[i].qiov->niov +1 >IOV_MAX ) { + merge =0 ; + } +if (merge) {size_t size;QEMUIOVector *qiov =qemu_mallocz (sizeof (*qiov));
qemu-common.h +4 -0
@@ -54,6 +54,10 @@ struct iovec {void *iov_base; size_t iov_len; }; +/* +* Use the same value as Linux for now. +*/ +#define IOV_MAX 1024#else #include <sys/uio.h> #endif
Anthony Liguori
AppliedQuoted 10 lines · Christoph Hellwig
If we go over the maximum number of iovecs support by syscall we get back EINVAL from the kernel which translate to I/O errors for the guest.
Add a
MAX_IOVdefintion for platforms that don't have it. For now we use the same 1024 define that's used on Linux and various other platforms, but until the windows block backend implements some kind of vectored I/O it doesn't matter.Signed-off-by Christoph Hellwig<[email protected]>
Applied. Thanks.
Regards,
Anthony Liguori
Quoted 34 lines
Index:
qemu/block.c
===================================================================block.c +4
-0@@ -1689,6 +1689,10 @@ static int multiwrite_merge(BlockDriverS merge = bs->drv->bdrv_merge_requests (bs,&reqs[outidx],&reqs[i]); } +if (reqs[outidx].qiov->niov + reqs[i].qiov->niov +1 >IOV_MAX ) { + merge =0 ; + } +if (merge) {size_t size;QEMUIOVector *qiov =qemu_mallocz (sizeof (*qiov));Index:
qemu/qemu-common.h
===================================================================qemu-common.h +4
-0@@ -54,6 +54,10 @@ struct iovec {void *iov_base; size_t iov_len; }; +/* +* Use the same value as Linux for now. +*/ +#define IOV_MAX 1024#else #include <sys/uio.h> #endif
Quoted 9 lines · Anthony Liguori
Quoted 8 lines · Christoph Hellwig
If we go over the maximum number of iovecs support by syscall we get back EINVAL from the kernel which translate to I/O errors for the guest.
Add a
MAX_IOVdefintion for platforms that don't have it. For now we use the same 1024 define that's used on Linux and various other platforms, but until the windows block backend implements some kind of vectored I/O it doesn't matter.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Christoph Hellwig<[email protected]>Applied. Thanks.
Can you also add it to the 0.12-stable series? There's tons of bug reports from users seeing this regression in qemu-0.12.