[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 21/42] qcow: cleanup qcow_co_pwritev_compressed to av
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 21/42] qcow: cleanup qcow_co_pwritev_compressed to avoid the recursion |
Date: |
Mon, 5 Sep 2016 20:13:33 +0200 |
From: Pavel Butsykin <address@hidden>
Now that the function uses a vector instead of a buffer, there is no
need to use recursive code.
Signed-off-by: Pavel Butsykin <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Denis V. Lunev <address@hidden>
CC: Jeff Cody <address@hidden>
CC: Markus Armbruster <address@hidden>
CC: Eric Blake <address@hidden>
CC: John Snow <address@hidden>
CC: Stefan Hajnoczi <address@hidden>
CC: Kevin Wolf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/block/qcow.c b/block/qcow.c
index 1b9c911..94f01b3 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -927,27 +927,17 @@ qcow_co_pwritev_compressed(BlockDriverState *bs, uint64_t
offset,
uint8_t *buf, *out_buf;
uint64_t cluster_offset;
+ buf = qemu_blockalign(bs, s->cluster_size);
if (bytes != s->cluster_size) {
- ret = -EINVAL;
-
- /* Zero-pad last write if image size is not cluster aligned */
- if (offset + bytes == bs->total_sectors << BDRV_SECTOR_BITS &&
- bytes < s->cluster_size)
+ if (bytes > s->cluster_size ||
+ offset + bytes != bs->total_sectors << BDRV_SECTOR_BITS)
{
- uint8_t *pad_buf = qemu_blockalign(bs, s->cluster_size);
- memset(pad_buf, 0, s->cluster_size);
- qemu_iovec_to_buf(qiov, 0, pad_buf, s->cluster_size);
- iov = (struct iovec) {
- .iov_base = pad_buf,
- .iov_len = s->cluster_size,
- };
- qemu_iovec_init_external(&hd_qiov, &iov, 1);
- ret = qcow_co_pwritev_compressed(bs, offset, bytes, &hd_qiov);
- qemu_vfree(pad_buf);
+ qemu_vfree(buf);
+ return -EINVAL;
}
- return ret;
+ /* Zero-pad last write if image size is not cluster aligned */
+ memset(buf + bytes, 0, s->cluster_size - bytes);
}
- buf = qemu_blockalign(bs, s->cluster_size);
qemu_iovec_to_buf(qiov, 0, buf, qiov->size);
out_buf = g_malloc(s->cluster_size);
--
1.8.3.1
- [Qemu-devel] [PULL 15/42] block: Convert bdrv_pwrite_compressed() to BdrvChild, (continued)
- [Qemu-devel] [PULL 15/42] block: Convert bdrv_pwrite_compressed() to BdrvChild, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 16/42] block/io: reuse bdrv_co_pwritev() for write compressed, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 19/42] vmdk: add vmdk_co_pwritev_compressed, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 13/42] nbd-server: Allow node name for nbd-server-add, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 14/42] block: switch blk_write_compressed() to byte-based interface, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 10/42] block: Accept node-name for drive-backup, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 11/42] block: Accept node-name for drive-mirror, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 18/42] qcow2: cleanup qcow2_co_pwritev_compressed to avoid the recursion, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 20/42] qcow: add qcow_co_pwritev_compressed, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 17/42] qcow2: add qcow2_co_pwritev_compressed, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 21/42] qcow: cleanup qcow_co_pwritev_compressed to avoid the recursion,
Kevin Wolf <=
- [Qemu-devel] [PULL 22/42] block: remove BlockDriver.bdrv_write_compressed, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 25/42] block: simplify blockdev-backup, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 24/42] block: simplify drive-backup, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 23/42] block/io: turn on dirty_bitmaps for the compressed writes, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 28/42] qemu-iotests: test backup compression in 055, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 26/42] drive-backup: added support for data compression, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 27/42] blockdev-backup: added support for data compression, Kevin Wolf, 2016/09/05
- [Qemu-devel] [PULL 32/42] coroutine: Let CoMutex remember who holds it, Kevin Wolf, 2016/09/05