From: Fam Zheng <famz@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
lvivier@redhat.com, qemu-block@nongnu.org, pl@kamp.de,
qemu-devel@nongnu.org, qemu-stable@nongnu.org,
Stefan Hajnoczi <stefanha@redhat.com>,
dgibson@redhat.com
Subject: Re: [Qemu-devel] [PATCH] virtio-blk: Fix double completion for werror=stop
Date: Mon, 16 Nov 2015 13:52:53 +0800 [thread overview]
Message-ID: <20151116055253.GA20672@ad.usersys.redhat.com> (raw)
In-Reply-To: <5645E2FE.3090803@redhat.com>
On Fri, 11/13 14:17, Paolo Bonzini wrote:
>
>
> On 13/11/2015 10:32, Fam Zheng wrote:
> > When a request R is absorbed by request M, it is appended to the
> > "mr_next" queue led by M, and is completed together with the completion
> > of M, in virtio_blk_rw_complete.
> >
> > With error policy equals stop, if M has an I/O error, now R also gets
> > prepended to the per device DMA restart queue, which will be retried
> > when VM resumes. It leads to a double completion (in symptoms of memory
> > corruption or use after free).
> >
> > Adding R to the queue is superfluous, only M needs to be in the queue.
> >
> > Fix this by marking request R as "merged" and skipping it in
> > virtio_blk_handle_rw_error.
> >
> > Cc: qemu-stable@nongnu.org
> > Signed-off-by: Fam Zheng <famz@redhat.com>
> > ---
> > hw/block/virtio-blk.c | 9 +++++++--
> > include/hw/virtio/virtio-blk.h | 1 +
> > 2 files changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> > index e70fccf..4871f2a 100644
> > --- a/hw/block/virtio-blk.c
> > +++ b/hw/block/virtio-blk.c
> > @@ -36,6 +36,7 @@ VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s)
> > req->in_len = 0;
> > req->next = NULL;
> > req->mr_next = NULL;
> > + req->merged = false;
> > return req;
> > }
> >
> > @@ -72,8 +73,11 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error,
> > VirtIOBlock *s = req->dev;
> >
> > if (action == BLOCK_ERROR_ACTION_STOP) {
> > - req->next = s->rq;
> > - s->rq = req;
> > + /* Merged requests don't need to be restarted. */
> > + if (!req->merged) {
> > + req->next = s->rq;
> > + s->rq = req;
> > + }
>
> I think it still needs to be queued, so that the request is migrated
> correctly. Should req->merged be checked in virtio_blk_dma_restart_bh
> instead?
Yes you're right.
Thanks,
Fam
prev parent reply other threads:[~2015-11-16 5:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-13 9:32 [Qemu-devel] [PATCH] virtio-blk: Fix double completion for werror=stop Fam Zheng
2015-11-13 10:48 ` Laurent Vivier
2015-11-13 13:17 ` Paolo Bonzini
2015-11-16 5:52 ` Fam Zheng [this message]
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=20151116055253.GA20672@ad.usersys.redhat.com \
--to=famz@redhat.com \
--cc=dgibson@redhat.com \
--cc=kwolf@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pl@kamp.de \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@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).