qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wen Congyang <wency@cn.fujitsu.com>
To: qemu-devl <qemu-devel@nongnu.org>, Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH] quorum: don't share qiov
Date: Fri, 30 Jan 2015 16:07:16 +0800	[thread overview]
Message-ID: <54CB3BB4.80406@cn.fujitsu.com> (raw)

If the child touches qiov->iov, it will cause unexpected results.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 block/quorum.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/block/quorum.c b/block/quorum.c
index cdc026c..ef0c1e9 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -165,6 +165,10 @@ static void quorum_aio_finalize(QuorumAIOCB *acb)
             qemu_vfree(acb->qcrs[i].buf);
             qemu_iovec_destroy(&acb->qcrs[i].qiov);
         }
+    } else {
+        for (i = 0; i <= acb->child_iter; i++) {
+            qemu_iovec_destroy(&acb->qcrs[i].qiov);
+        }
     }
 
     g_free(acb->qcrs);
@@ -709,8 +713,12 @@ static BlockAIOCB *quorum_aio_writev(BlockDriverState *bs,
                                       cb, opaque);
     int i;
 
+    acb->child_iter = s->num_children - 1;
     for (i = 0; i < s->num_children; i++) {
-        acb->qcrs[i].aiocb = bdrv_aio_writev(s->bs[i], sector_num, qiov,
+        qemu_iovec_init(&acb->qcrs[i].qiov, acb->qiov->niov);
+        qemu_iovec_concat(&acb->qcrs[i].qiov, acb->qiov, 0, acb->qiov->size);
+        acb->qcrs[i].aiocb = bdrv_aio_writev(s->bs[i], sector_num,
+                                             &acb->qcrs[i].qiov,
                                              nb_sectors, &quorum_aio_cb,
                                              &acb->qcrs[i]);
     }
-- 
2.1.0

             reply	other threads:[~2015-01-30  8:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-30  8:07 Wen Congyang [this message]
2015-01-30 13:39 ` [Qemu-devel] [PATCH] quorum: don't share qiov Kevin Wolf
2015-02-02  1:19   ` Wen Congyang
2015-02-03  9:22     ` Kevin Wolf
2015-02-03 11:01       ` Paolo Bonzini
2015-02-09  2:10         ` Wen Congyang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54CB3BB4.80406@cn.fujitsu.com \
    --to=wency@cn.fujitsu.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).