Patchwork block: fix qcow2_co_flush deadlock

login
register
mail settings
Submitter Robert Wang
Date Oct. 27, 2011, 9:22 a.m.
Message ID <1319707348-21768-1-git-send-email-wdongxu@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/122097/
State New
Headers show

Comments

Robert Wang - Oct. 27, 2011, 9:22 a.m.
If qcow2_cache_flush failed, s->lock will not be unlock.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
---
 block/qcow2.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Kevin Wolf - Oct. 27, 2011, 9:46 a.m.
Am 27.10.2011 11:22, schrieb Dong Xu Wang:
> If qcow2_cache_flush failed, s->lock will not be unlock.
> 
> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>

Thanks, applied to the block branch.

Kevin

Patch

diff --git a/block/qcow2.c b/block/qcow2.c
index a181932..ef057d3 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1113,11 +1113,13 @@  static int qcow2_co_flush(BlockDriverState *bs)
     qemu_co_mutex_lock(&s->lock);
     ret = qcow2_cache_flush(bs, s->l2_table_cache);
     if (ret < 0) {
+        qemu_co_mutex_unlock(&s->lock);
         return ret;
     }
 
     ret = qcow2_cache_flush(bs, s->refcount_block_cache);
     if (ret < 0) {
+        qemu_co_mutex_unlock(&s->lock);
         return ret;
     }
     qemu_co_mutex_unlock(&s->lock);