[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/69] qcow2: Do not return new value after refcount
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 17/69] qcow2: Do not return new value after refcount update |
Date: |
Fri, 27 Feb 2015 18:18:15 +0000 |
From: Max Reitz <address@hidden>
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>
Signed-off-by: Kevin Wolf <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 e124a54..1a85bcd 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -631,8 +631,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,
@@ -648,7 +647,7 @@ int qcow2_update_cluster_refcount(BlockDriverState *bs,
return ret;
}
- return qcow2_get_refcount(bs, cluster_index);
+ return 0;
}
@@ -976,13 +975,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;
@@ -1017,11 +1018,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] [PULL 11/69] tests: Prepare virtio-blk-test for multi-arch implementation, (continued)
- [Qemu-devel] [PULL 11/69] tests: Prepare virtio-blk-test for multi-arch implementation, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 10/69] libqos: Change use of pointers to uint64_t in virtio, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 12/69] libqos: Remove PCI assumptions in constants of virtio driver, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 13/69] libqos: Add malloc generic, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 06/69] sheepdog: selectable object size support, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 16/69] qcow2: Add refcount_bits to format-specific info, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 14/69] libqos: Add virtio MMIO support, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 15/69] qcow2: Add two new fields to BDRVQcowState, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 18/69] qcow2: Only return status from qcow2_get_refcount, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 20/69] qcow2: Use 64 bits for refcount values, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 17/69] qcow2: Do not return new value after refcount update,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 19/69] qcow2: Use unsigned addend for update_refcount(), Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 21/69] qcow2: Helper for refcount array reallocation, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 22/69] qcow2: Helper function for refcount modification, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 24/69] qcow2: Open images with refcount order != 4, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 26/69] qcow2: Use symbolic macros in qcow2_amend_options, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 23/69] qcow2: More helpers for refcount modification, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 25/69] qcow2: refcount_order parameter for qcow2_create2, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 28/69] qcow2: Allow creation with refcount order != 4, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 29/69] iotests: Add test for different refcount widths, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 27/69] iotests: Prepare for refcount_bits option, Stefan Hajnoczi, 2015/02/27