From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:58795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QUFVH-0002jc-LE for qemu-devel@nongnu.org; Wed, 08 Jun 2011 05:56:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QUFVG-00077g-1e for qemu-devel@nongnu.org; Wed, 08 Jun 2011 05:56:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6014) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QUFVF-00077Y-K0 for qemu-devel@nongnu.org; Wed, 08 Jun 2011 05:56:45 -0400 From: Kevin Wolf Date: Wed, 8 Jun 2011 11:59:33 +0200 Message-Id: <1307527173-1624-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH v2] qcow2: Fix in-flight list after qcow2_cache_put failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, hch@lst.de 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 Reviewed-by: Christoph Hellwig --- v2: - When waiting for a request we depend on, the dependency must not be removed from the in-flight list. Caught by qemu-iotests 011. 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