[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/17] qcow2: Handle EAGAIN returned from update_refc
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 02/17] qcow2: Handle EAGAIN returned from update_refcount |
Date: |
Thu, 2 Jul 2015 10:19:34 +0100 |
From: Jindřich Makovička <address@hidden>
Fixes a crash during image compression
Signed-off-by: Jindřich Makovička <address@hidden>
Tested-by: Richard W.M. Jones <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/qcow2-refcount.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 0632fc3..b0ee42d 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;
}
--
2.4.3
- [Qemu-devel] [PULL 00/17] Block patches, Stefan Hajnoczi, 2015/07/02
- [Qemu-devel] [PULL 01/17] block/iscsi: add support for request timeouts, Stefan Hajnoczi, 2015/07/02
- [Qemu-devel] [PULL 02/17] qcow2: Handle EAGAIN returned from update_refcount,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 03/17] qapi: Rename 'dirty-bitmap' mode to 'incremental', Stefan Hajnoczi, 2015/07/02
- [Qemu-devel] [PULL 04/17] blockdev: no need to drain+flush in hmp_drive_del, Stefan Hajnoczi, 2015/07/02
- [Qemu-devel] [PULL 05/17] timer: Move NANOSECONDS_PER_SECONDS to timer.h, Stefan Hajnoczi, 2015/07/02
- [Qemu-devel] [PULL 06/17] timer: Use a single definition of NSEC_PER_SEC for the whole codebase, Stefan Hajnoczi, 2015/07/02
- [Qemu-devel] [PULL 07/17] block: Add bdrv_get_block_status_above, Stefan Hajnoczi, 2015/07/02
- [Qemu-devel] [PULL 08/17] qmp: Add optional bool "unmap" to drive-mirror, Stefan Hajnoczi, 2015/07/02
- [Qemu-devel] [PULL 09/17] mirror: Do zero write on target if sectors not allocated, Stefan Hajnoczi, 2015/07/02
- [Qemu-devel] [PULL 10/17] block: Fix dirty bitmap in bdrv_co_discard, Stefan Hajnoczi, 2015/07/02
- [Qemu-devel] [PULL 11/17] block: Remove bdrv_reset_dirty, Stefan Hajnoczi, 2015/07/02
- [Qemu-devel] [PULL 12/17] qemu-iotests: Make block job methods common, Stefan Hajnoczi, 2015/07/02