From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <famz@redhat.com>,
andrey@xdel.ru, sviatoslav.pestov@gmail.com
Subject: [Qemu-devel] [PATCH v2 1/2] block: fix overlapping multiwrite requests
Date: Wed, 30 Jul 2014 09:53:30 +0100 [thread overview]
Message-ID: <1406710411-26373-2-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1406710411-26373-1-git-send-email-stefanha@redhat.com>
When request A is a strict superset of request B:
AAAAAAAA
BBBB
multiwrite_merge() merges them as follows:
AABBBB
The tail of request A should have been included:
AABBBBAA
This patch fixes data loss but this code path is probably rare. Since
guests cannot assume ordering between in-flight requests, few
applications submit overlapping write requests.
Reported-by: Slava Pestov <sviatoslav.pestov@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/block.c b/block.c
index 8cf519b..0a3ac43 100644
--- a/block.c
+++ b/block.c
@@ -4498,6 +4498,12 @@ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs,
// Add the second request
qemu_iovec_concat(qiov, reqs[i].qiov, 0, reqs[i].qiov->size);
+ // Add tail of first request, if necessary
+ if (qiov->size < reqs[outidx].qiov->size) {
+ qemu_iovec_concat(qiov, reqs[outidx].qiov, qiov->size,
+ reqs[outidx].qiov->size - qiov->size);
+ }
+
reqs[outidx].nb_sectors = qiov->size >> 9;
reqs[outidx].qiov = qiov;
--
1.9.3
next prev parent reply other threads:[~2014-07-30 8:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-30 8:53 [Qemu-devel] [PATCH v2 0/2] block: fix multiwrite_merge() overlapping requests Stefan Hajnoczi
2014-07-30 8:53 ` Stefan Hajnoczi [this message]
2014-07-30 11:23 ` [Qemu-devel] [PATCH v2 1/2] block: fix overlapping multiwrite requests Eric Blake
2014-07-31 7:41 ` Benoît Canet
2014-07-30 8:53 ` [Qemu-devel] [PATCH v2 2/2] qemu-iotests: add multiwrite test cases Stefan Hajnoczi
2014-07-30 11:19 ` Eric Blake
2014-07-31 7:46 ` Benoît Canet
2014-08-29 13:10 ` [Qemu-devel] [PATCH v2 0/2] block: fix multiwrite_merge() overlapping requests Stefan Hajnoczi
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=1406710411-26373-2-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=andrey@xdel.ru \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sviatoslav.pestov@gmail.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).