[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 03/24] qcow2: Do not return new value after refco
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v6 03/24] qcow2: Do not return new value after refcount update |
Date: |
Tue, 10 Feb 2015 15:28:45 -0500 |
qcow2_update_cluster_refcount() does not have any quick access to the
new refcount value, it has to call qcow2_get_refcount(). Some callers do
not need that new value at all, others call qcow2_get_refcount()
themselves anyway (albeit in a different code path, which can however be
easily changed), therefore there is no advantage in making
qcow2_update_cluster_refcount() return the new value. Drop it.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
block/qcow2-refcount.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index f43093f..69c6822 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -643,8 +643,7 @@ fail:
/*
* Increases or decreases the refcount of a given cluster.
*
- * If the return value is non-negative, it is the new refcount of the cluster.
- * If it is negative, it is -errno and indicates an error.
+ * On success 0 is returned; on failure -errno is returned.
*/
int qcow2_update_cluster_refcount(BlockDriverState *bs,
int64_t cluster_index,
@@ -660,7 +659,7 @@ int qcow2_update_cluster_refcount(BlockDriverState *bs,
return ret;
}
- return qcow2_get_refcount(bs, cluster_index);
+ return 0;
}
@@ -988,13 +987,15 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
break;
}
if (addend != 0) {
- refcount = qcow2_update_cluster_refcount(bs,
+ ret = qcow2_update_cluster_refcount(bs,
cluster_index, addend,
QCOW2_DISCARD_SNAPSHOT);
- } else {
- refcount = qcow2_get_refcount(bs, cluster_index);
+ if (ret < 0) {
+ goto fail;
+ }
}
+ refcount = qcow2_get_refcount(bs, cluster_index);
if (refcount < 0) {
ret = refcount;
goto fail;
@@ -1029,11 +1030,15 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
if (addend != 0) {
- refcount = qcow2_update_cluster_refcount(bs, l2_offset >>
- s->cluster_bits, addend, QCOW2_DISCARD_SNAPSHOT);
- } else {
- refcount = qcow2_get_refcount(bs, l2_offset >>
s->cluster_bits);
+ ret = qcow2_update_cluster_refcount(bs, l2_offset >>
+ s->cluster_bits,
+ addend,
+ QCOW2_DISCARD_SNAPSHOT);
+ if (ret < 0) {
+ goto fail;
+ }
}
+ refcount = qcow2_get_refcount(bs, l2_offset >> s->cluster_bits);
if (refcount < 0) {
ret = refcount;
goto fail;
--
2.1.0
- [Qemu-devel] [PATCH v6 00/24] qcow2: Support refcount orders != 4, Max Reitz, 2015/02/10
- [Qemu-devel] [PATCH v6 01/24] qcow2: Add two new fields to BDRVQcowState, Max Reitz, 2015/02/10
- [Qemu-devel] [PATCH v6 03/24] qcow2: Do not return new value after refcount update,
Max Reitz <=
- [Qemu-devel] [PATCH v6 02/24] qcow2: Add refcount_bits to format-specific info, Max Reitz, 2015/02/10
- [Qemu-devel] [PATCH v6 04/24] qcow2: Only return status from qcow2_get_refcount, Max Reitz, 2015/02/10
- [Qemu-devel] [PATCH v6 05/24] qcow2: Use unsigned addend for update_refcount(), Max Reitz, 2015/02/10
- [Qemu-devel] [PATCH v6 06/24] qcow2: Use 64 bits for refcount values, Max Reitz, 2015/02/10
- [Qemu-devel] [PATCH v6 10/24] qcow2: Open images with refcount order != 4, Max Reitz, 2015/02/10