From 060bee8943c27d4d53f65570fafaa2559fcd87c3 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Fri, 7 Dec 2012 18:08:45 +0100 Subject: 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 --- block/qcow2-cluster.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'block/qcow2-cluster.c') diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 94b7f136fa..c4752ee812 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -856,7 +856,7 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, * Return 0 on success and -errno in error cases */ int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, - int n_start, int n_end, int *num, QCowL2Meta *m) + int n_start, int n_end, int *num, uint64_t *host_offset, QCowL2Meta *m) { BDRVQcowState *s = bs->opaque; int l2_index, ret, sectors; @@ -929,7 +929,6 @@ again: /* If there is something left to allocate, do that now */ *m = (QCowL2Meta) { - .cluster_offset = cluster_offset, .nb_clusters = 0, }; qemu_co_queue_init(&m->dependent_requests); @@ -977,9 +976,11 @@ again: int alloc_n_start = keep_clusters == 0 ? n_start : 0; int nb_sectors = MIN(requested_sectors, avail_sectors); + if (keep_clusters == 0) { + cluster_offset = alloc_cluster_offset; + } + *m = (QCowL2Meta) { - .cluster_offset = keep_clusters == 0 ? - alloc_cluster_offset : cluster_offset, .alloc_offset = alloc_cluster_offset, .offset = alloc_offset & ~(s->cluster_size - 1), .nb_clusters = nb_clusters, @@ -1007,6 +1008,7 @@ again: assert(sectors > n_start); *num = sectors - n_start; + *host_offset = cluster_offset; return 0; -- cgit v1.2.3