summaryrefslogtreecommitdiff
path: root/block/qcow2-refcount.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2012-02-23 15:40:55 +0100
committerKevin Wolf <kwolf@redhat.com>2012-04-20 15:57:28 +0200
commit8e37f681d58bbe166c20559e77fd55b1cb8e6e4b (patch)
tree5c98c646b56e21ac9f04b26a6248ee93331d313b /block/qcow2-refcount.c
parentb0b6862e5e1a1394e0ab3d5da94ba8b0da8664e2 (diff)
downloadqemu-8e37f681d58bbe166c20559e77fd55b1cb8e6e4b.tar.gz
qcow2: Ignore reserved bits in L1/L2 entries
This changes the still existing places that assume that the only flags are QCOW_OFLAG_COPIED and QCOW_OFLAG_COMPRESSED to properly mask out reserved bits. It does not convert bdrv_check yet. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/qcow2-refcount.c')
-rw-r--r--block/qcow2-refcount.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 6c383373de..84fa343248 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -702,9 +702,8 @@ void qcow2_free_any_clusters(BlockDriverState *bs,
return;
}
- qcow2_free_clusters(bs, cluster_offset, nb_clusters << s->cluster_bits);
-
- return;
+ qcow2_free_clusters(bs, cluster_offset & L2E_OFFSET_MASK,
+ nb_clusters << s->cluster_bits);
}
@@ -764,7 +763,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
l2_offset = l1_table[i];
if (l2_offset) {
old_l2_offset = l2_offset;
- l2_offset &= ~QCOW_OFLAG_COPIED;
+ l2_offset &= L1E_OFFSET_MASK;
ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset,
(void**) &l2_table);
@@ -796,10 +795,11 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
/* compressed clusters are never modified */
refcount = 2;
} else {
+ uint64_t cluster_index = (offset & L2E_OFFSET_MASK) >> s->cluster_bits;
if (addend != 0) {
- refcount = update_cluster_refcount(bs, offset >> s->cluster_bits, addend);
+ refcount = update_cluster_refcount(bs, cluster_index, addend);
} else {
- refcount = get_refcount(bs, offset >> s->cluster_bits);
+ refcount = get_refcount(bs, cluster_index);
}
if (refcount < 0) {