[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/14] qcow2: Fix in-flight list after qcow2_cache_p
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 06/14] qcow2: Fix in-flight list after qcow2_cache_put failure |
Date: |
Wed, 15 Jun 2011 16:03:05 +0200 |
If qcow2_cache_put returns an error during cluster allocation and the
allocation fails, it must be removed from the list of in-flight allocations.
Otherwise we'd get a loop in the list when the ACB is used for the next
allocation.
Luckily, this qcow2_cache_put shouldn't fail anyway because the L2 table is
only read, so that qcow2_cache_put doesn't even involve I/O.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Christoph Hellwig <address@hidden>
---
block/qcow2-cluster.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index c9e7bbd..882f50a 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -796,8 +796,8 @@ int qcow2_alloc_cluster_offset(BlockDriverState *bs,
uint64_t offset,
m->depends_on = old_alloc;
m->nb_clusters = 0;
*num = 0;
- ret = 0;
- goto fail;
+
+ goto out_wait_dependency;
}
}
}
@@ -812,7 +812,6 @@ int qcow2_alloc_cluster_offset(BlockDriverState *bs,
uint64_t offset,
cluster_offset = qcow2_alloc_clusters(bs, nb_clusters * s->cluster_size);
if (cluster_offset < 0) {
- QLIST_REMOVE(m, next_in_flight);
ret = cluster_offset;
goto fail;
}
@@ -825,7 +824,7 @@ int qcow2_alloc_cluster_offset(BlockDriverState *bs,
uint64_t offset,
out:
ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
if (ret < 0) {
- return ret;
+ goto fail_put;
}
m->nb_available = MIN(nb_clusters << (s->cluster_bits - 9), n_end);
@@ -835,8 +834,13 @@ out:
return 0;
+out_wait_dependency:
+ return qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
+
fail:
qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
+fail_put:
+ QLIST_REMOVE(m, next_in_flight);
return ret;
}
--
1.7.5.2
- [Qemu-devel] [PULL 00/14] Block patches, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 01/14] block/rbd: Remove unused local variable, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 04/14] vdi: Avoid direct AIO callback, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 02/14] qcow2: Avoid direct AIO callback, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 06/14] qcow2: Fix in-flight list after qcow2_cache_put failure,
Kevin Wolf <=
- [Qemu-devel] [PATCH 05/14] Replaced tabs with spaces in block.h and block_int.h, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 07/14] ide: Split error status from status register, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 08/14] ide: Fix ide_drive_pio_state_needed(), Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 09/14] ide: Add forgotten VMSTATE_END_OF_LIST in subsection, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 10/14] make dma_bdrv_io available to drivers, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 11/14] ide: allow other dma comands than read and write, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 13/14] ide: Clear error_status after restarting flush, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 03/14] qcow: Avoid direct AIO callback, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 14/14] Allow nested qemu_bh_poll() after BH deletion, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 12/14] ide: add TRIM support, Kevin Wolf, 2011/06/15