diff options
author | Pavel Butsykin <pbutsykin@virtuozzo.com> | 2016-07-22 11:17:47 +0300 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2016-09-05 19:06:48 +0200 |
commit | 655923df4be82ac23efc6862d35f569d05824e42 (patch) | |
tree | f7aa550bd04d1af7bfe7bbd8d65a2bf9ba1e21b8 /block | |
parent | f2b95a12317bf827f3f734353ffe0e1ec41942ae (diff) | |
download | qemu-655923df4be82ac23efc6862d35f569d05824e42.zip |
qcow: cleanup qcow_co_pwritev_compressed to avoid the recursion
Now that the function uses a vector instead of a buffer, there is no
need to use recursive code.
Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Jeff Cody <jcody@redhat.com>
CC: Markus Armbruster <armbru@redhat.com>
CC: Eric Blake <eblake@redhat.com>
CC: John Snow <jsnow@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/qcow.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/block/qcow.c b/block/qcow.c index 1b9c91128a..94f01b3d0c 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); |