aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorJindřich Makovička <makovick@gmail.com>2015-06-24 07:05:25 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2015-07-02 09:20:18 +0100
commit3e5feb6202149e8a963a33b911216e40d790f1d7 (patch)
tree15fbf54f780c96777566749d8d23051e1d7d8c8a /block
parent5dd7a535b71a0f2f8e7af75c5d694174359ce323 (diff)
qcow2: Handle EAGAIN returned from update_refcount
Fixes a crash during image compression Signed-off-by: Jindřich Makovička <makovick@gmail.com> Tested-by: Richard W.M. Jones <rjones@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/qcow2-refcount.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 0632fc3bc0..b0ee42d81b 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -940,19 +940,21 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size)
}
free_in_cluster = s->cluster_size - offset_into_cluster(s, offset);
- if (!offset || free_in_cluster < size) {
- int64_t new_cluster = alloc_clusters_noref(bs, s->cluster_size);
- if (new_cluster < 0) {
- return new_cluster;
- }
+ do {
+ if (!offset || free_in_cluster < size) {
+ int64_t new_cluster = alloc_clusters_noref(bs, s->cluster_size);
+ if (new_cluster < 0) {
+ return new_cluster;
+ }
- if (!offset || ROUND_UP(offset, s->cluster_size) != new_cluster) {
- offset = new_cluster;
+ if (!offset || ROUND_UP(offset, s->cluster_size) != new_cluster) {
+ offset = new_cluster;
+ }
}
- }
- assert(offset);
- ret = update_refcount(bs, offset, size, 1, false, QCOW2_DISCARD_NEVER);
+ assert(offset);
+ ret = update_refcount(bs, offset, size, 1, false, QCOW2_DISCARD_NEVER);
+ } while (ret == -EAGAIN);
if (ret < 0) {
return ret;
}