diff options
author | Kevin Wolf <kwolf@redhat.com> | 2012-12-07 18:08:45 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2012-12-13 15:37:59 +0100 |
commit | 060bee8943c27d4d53f65570fafaa2559fcd87c3 (patch) | |
tree | b094d4562a32ddddfa3296dd99b8798e3fdcdad2 /block/qcow2.c | |
parent | cf5c1a231ee99ac21fe8258faf50bb1f65884343 (diff) |
qcow2: Drop l2meta.cluster_offset
There's no real reason to have an l2meta for normal requests that don't
allocate anything. Before we can get rid of it, we must return the host
cluster offset in a different way.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/qcow2.c')
-rw-r--r-- | block/qcow2.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/block/qcow2.c b/block/qcow2.c index 71f870d829..66ca12f94e 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -799,7 +799,7 @@ static coroutine_fn int qcow2_co_writev(BlockDriverState *bs, } ret = qcow2_alloc_cluster_offset(bs, sector_num << 9, - index_in_cluster, n_end, &cur_nr_sectors, l2meta); + index_in_cluster, n_end, &cur_nr_sectors, &cluster_offset, l2meta); if (ret < 0) { goto fail; } @@ -809,7 +809,6 @@ static coroutine_fn int qcow2_co_writev(BlockDriverState *bs, qcow2_mark_dirty(bs); } - cluster_offset = l2meta->cluster_offset; assert((cluster_offset & 511) == 0); qemu_iovec_reset(&hd_qiov); @@ -1132,6 +1131,7 @@ static int preallocate(BlockDriverState *bs) { uint64_t nb_sectors; uint64_t offset; + uint64_t host_offset = 0; int num; int ret; QCowL2Meta meta; @@ -1139,18 +1139,18 @@ static int preallocate(BlockDriverState *bs) nb_sectors = bdrv_getlength(bs) >> 9; offset = 0; qemu_co_queue_init(&meta.dependent_requests); - meta.cluster_offset = 0; while (nb_sectors) { num = MIN(nb_sectors, INT_MAX >> 9); - ret = qcow2_alloc_cluster_offset(bs, offset, 0, num, &num, &meta); + ret = qcow2_alloc_cluster_offset(bs, offset, 0, num, &num, + &host_offset, &meta); if (ret < 0) { return ret; } ret = qcow2_alloc_cluster_link_l2(bs, &meta); if (ret < 0) { - qcow2_free_any_clusters(bs, meta.cluster_offset, meta.nb_clusters); + qcow2_free_any_clusters(bs, meta.alloc_offset, meta.nb_clusters); return ret; } @@ -1169,10 +1169,10 @@ static int preallocate(BlockDriverState *bs) * all of the allocated clusters (otherwise we get failing reads after * EOF). Extend the image to the last allocated sector. */ - if (meta.cluster_offset != 0) { + if (host_offset != 0) { uint8_t buf[512]; memset(buf, 0, 512); - ret = bdrv_write(bs->file, (meta.cluster_offset >> 9) + num - 1, buf, 1); + ret = bdrv_write(bs->file, (host_offset >> 9) + num - 1, buf, 1); if (ret < 0) { return ret; } |