[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL for-2.5 7/7] virtio-blk: Fix double completion for we
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL for-2.5 7/7] virtio-blk: Fix double completion for werror=stop |
Date: |
Tue, 17 Nov 2015 19:17:28 +0800 |
From: Fam Zheng <address@hidden>
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.
During DMA restart in virtio_blk_dma_restart_bh, requests in s->rq are
parsed and submitted again, possibly with a stale req->mr_next. It could
be a problem if the request merging in virtio_blk_handle_request hasn't
refreshed every mr_next pointer, in which case, virtio_blk_rw_complete
could walk through unexpected requests following the stale pointers.
Fix this by unsetting the pointer in virtio_blk_rw_complete. It is safe
because this req is either completed and freed right away, or it will be
restarted and parsed from scratch out of the vq later.
Signed-off-by: Fam Zheng <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
hw/block/virtio-blk.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index e70fccf..848f3fe 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -112,6 +112,10 @@ static void virtio_blk_rw_complete(void *opaque, int ret)
* happen on the other side of the migration).
*/
if (virtio_blk_handle_rw_error(req, -ret, is_read)) {
+ /* Break the link in case the next request is added to the
+ * restart queue and is going to be parsed from the ring again.
+ */
+ req->mr_next = NULL;
continue;
}
}
--
2.5.0
- [Qemu-devel] [PULL for-2.5 0/7] Block patches, Stefan Hajnoczi, 2015/11/17
- [Qemu-devel] [PULL for-2.5 1/7] docs: update bitmaps.md, Stefan Hajnoczi, 2015/11/17
- [Qemu-devel] [PULL for-2.5 2/7] tests: Ignore recent test binaries, Stefan Hajnoczi, 2015/11/17
- [Qemu-devel] [PULL for-2.5 3/7] tpm: avoid clang shifting negative signed warning, Stefan Hajnoczi, 2015/11/17
- [Qemu-devel] [PULL for-2.5 4/7] disas/arm: avoid clang shifting negative signed warning, Stefan Hajnoczi, 2015/11/17
- [Qemu-devel] [PULL for-2.5 5/7] aio-epoll: Fix use-after-free of node, Stefan Hajnoczi, 2015/11/17
- [Qemu-devel] [PULL for-2.5 6/7] block: make 'stats-interval' an array of ints instead of a string, Stefan Hajnoczi, 2015/11/17
- [Qemu-devel] [PULL for-2.5 7/7] virtio-blk: Fix double completion for werror=stop,
Stefan Hajnoczi <=
- Re: [Qemu-devel] [PULL for-2.5 0/7] Block patches, Peter Maydell, 2015/11/17