Patchwork [v2,2/2] qcow2: lock on prealloc

login
register
mail settings
Submitter Zhiyong Wu
Date May 7, 2012, 8:51 a.m.
Message ID <1336380663-29742-1-git-send-email-zwu.kernel@gmail.com>
Download mbox | patch
Permalink /patch/157278/
State New
Headers show

Comments

Zhiyong Wu - May 7, 2012, 8:51 a.m.
From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

preallocate() will be locked.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 block/qcow2.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Kevin Wolf - May 7, 2012, 2:54 p.m.
Am 07.05.2012 10:51, schrieb zwu.kernel@gmail.com:
> From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
> 
> preallocate() will be locked.
> 
> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

Thanks, applied both to the block branch for 1.1.

Kevin

Patch

diff --git a/block/qcow2.c b/block/qcow2.c
index 8c60a6f..ee4678f 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1192,7 +1192,10 @@  static int qcow2_create2(const char *filename, int64_t total_size,
 
     /* And if we're supposed to preallocate metadata, do that now */
     if (prealloc) {
+        BDRVQcowState *s = bs->opaque;
+        qemu_co_mutex_lock(&s->lock);
         ret = preallocate(bs);
+        qemu_co_mutex_unlock(&s->lock);
         if (ret < 0) {
             goto out;
         }