[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 38/44] block: limited request size in write zeroes
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL v2 38/44] block: limited request size in write zeroes unsupported path |
Date: |
Mon, 12 Jan 2015 16:40:28 +0000 |
From: Peter Lieven <address@hidden>
If bs->bl.max_write_zeroes is large and we end up in the unsupported
path we might allocate a lot of memory for the iovector and/or even
generate an oversized requests.
Fix this by limiting the request by the minimum of the reported
maximum transfer size or 16MB (32768 sectors).
Reported-by: Denis V. Lunev <address@hidden>
Signed-off-by: Peter Lieven <address@hidden>
Reviewed-by: Denis V. Lunev <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index e76a223..371d0f6 100644
--- a/block.c
+++ b/block.c
@@ -3244,6 +3244,9 @@ static int coroutine_fn
bdrv_co_do_write_zeroes(BlockDriverState *bs,
if (ret == -ENOTSUP) {
/* Fall back to bounce buffer if write zeroes is unsupported */
+ int max_xfer_len = MIN_NON_ZERO(bs->bl.max_transfer_length,
+ MAX_WRITE_ZEROES_DEFAULT);
+ num = MIN(num, max_xfer_len);
iov.iov_len = num * BDRV_SECTOR_SIZE;
if (iov.iov_base == NULL) {
iov.iov_base = qemu_try_blockalign(bs, num * BDRV_SECTOR_SIZE);
@@ -3260,7 +3263,7 @@ static int coroutine_fn
bdrv_co_do_write_zeroes(BlockDriverState *bs,
/* Keep bounce buffer around if it is big enough for all
* all future requests.
*/
- if (num < max_write_zeroes) {
+ if (num < max_xfer_len) {
qemu_vfree(iov.iov_base);
iov.iov_base = NULL;
}
--
2.1.0
- [Qemu-devel] [PULL v2 34/44] QSLIST: add lock-free operations, (continued)
- [Qemu-devel] [PULL v2 34/44] QSLIST: add lock-free operations, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 35/44] coroutine: rewrite pool to avoid mutex, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 26/44] block/raw-posix.c: Fixes raw_getlength() on Mac OS X so that it reports the correct length of a real CD, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 36/44] coroutine: drop qemu_coroutine_adjust_pool_size, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 25/44] libqos: Add virtio MMIO support, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 21/44] libqos: Change use of pointers to uint64_t in virtio, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 24/44] libqos: Add malloc generic, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 39/44] block: Split BLOCK_OP_TYPE_COMMIT to BLOCK_OP_TYPE_COMMIT_{SOURCE, TARGET}, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 20/44] libqos: Convert malloc-pc allocator to a generic allocator, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 23/44] libqos: Remove PCI assumptions in constants of virtio driver, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 38/44] block: limited request size in write zeroes unsupported path,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL v2 37/44] coroutine: try harder not to delete coroutines, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 41/44] nvme: Fix get/set number of queues feature, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 40/44] ide: Implement VPD response for ATAPI, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 22/44] tests: Prepare virtio-blk-test for multi-arch implementation, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 42/44] MAINTAINERS: Update email addresses for Chrysostomos Nanakos, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 44/44] NVMe: Set correct VS Value for 1.1 Compliant Controllers, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 43/44] MAINTAINERS: Add migration/block* to block subsystem, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 27/44] .gitignore: Ignore generated "common.env", Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 01/44] qemu-iotests: Remove 091 from quick group, Stefan Hajnoczi, 2015/01/12
- [Qemu-devel] [PULL v2 28/44] qemu-iotests: Replace "/bin/true" with "true", Stefan Hajnoczi, 2015/01/12