virtio-blk: Release s->rq queue at system_reset
PATCH 1/1 virtio-blk: Release s->rq queue at system_reset
At system_reset, there is no point in retrying the queued request, because the driver that issued the request won't be around any more.
--- hw/block/virtio-blk.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/block/virtio-blk.c +6 -0
@@ -654,6 +654,7 @@ static void virtio_blk_reset(VirtIODevice *vdev) {VirtIOBlock *s =VIRTIO_BLK (vdev);AioContext *ctx; +VirtIOBlockReq *req;/* * This should cancel pending requests, but can't do nicely until there
@@ -661,6 +662,11 @@ static void virtio_blk_reset(VirtIODevice *vdev)*/ ctx =blk_get_aio_context (s->blk);aio_context_acquire (ctx); +while (s->rq) { + req = s->rq; + s->rq = req->next; +virtio_blk_free_request (req); + }blk_drain (s->blk);if (s->dataplane) {
Signature · 1 line
2.7.4
Fam,
Quoted 25 lines · Fam Zheng
At
system_reset, there is no point in retrying the queued request, because the driver that issued the request won't be around any more.Analyzed-by Laszlo Ersek <[email protected]>Reported-by Laszlo Ersek <[email protected]>Signed-off-by Fam Zheng <[email protected]>--- hw/block/virtio-blk.c | 6 ++++++ 1 file changed, 6 insertions(+)hw/block/virtio-blk.c +1
-0@@ -654,6 +654,7 @@ static void virtio_blk_reset(VirtIODevice *vdev) {VirtIOBlock *s =VIRTIO_BLK (vdev);AioContext *ctx; +VirtIOBlockReq *req;/* * This should cancel pending requests, but can't do nicely until there @@ -661,6 +662,11 @@ static void virtio_blk_reset(VirtIODevice *vdev)*/
hw/block/virtio-blk.c static void virtio_blk_reset(VirtIODevice *vdev) · line 672
Quoted 10 lines
hw/block/virtio-blk.c +5
-0ctx =blk_get_aio_context (s->blk);aio_context_acquire (ctx); +while (s->rq) { + req = s->rq; + s->rq = req->next; +virtio_blk_free_request (req); + }blk_drain (s->blk);if (s->dataplane) {
The comment
/*
* This should cancel pending requests, but can't do nicely until there
* are per-device request lists.
*/
dates back to
commit 6e02c38dadfe4cf02b0da6135adfd8d9352b90e1
Author: aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> Date: Thu Dec 4 19:52:44 2008 +0000
Add virtio-blk support
Virtio-blk is a paravirtual block device based on VirtIO. It can be used by specifying the if=virtio parameter to the -drive parameter.
When using -enable-kvm, it can achieve very good performance compared to IDE or SCSI.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5870 c046a42c-6fe2-441c-8c8c-71466251a162
I think the comment is obsolete now, the idea that it expresses was actually fixed in the following commit, in my opinion:
commit 6e40b3bfc7e82823cf4df5f0bf668f56db41e53a
Author: Alexander Yarygin <[email protected]> Date: Wed Jun 17 13:37:20 2015 +0300
virtio-blk: Use blk_drain() to drain IO requests
Each call of the virtio_blk_reset() function calls blk_drain_all(), which works for all existing BlockDriverStates, while draining only one is needed.
This patch replaces blk_drain_all() by blk_drain() in virtio_blk_reset(). virtio_blk_data_plane_stop() should be called after draining because it restores vblk->complete_request.
Message-id: [email protected]
So how about turning this patch into a two part series: the first patch should drop the comment, and reference 6e40b3bfc7e82823cf4df5f0bf668f56db41e53a, while the second patch should be this patch?
For this patch:
I definitely recommend that Stefan review this patch too.
Thanks!
Laszlo
Quoted 4 lines · Laszlo Ersek
So how about turning this patch into a two part series: the first patch should drop the comment, and reference
6e40b3bfc7e82823cf4df5f0bf668f56db41e53a, while the second patch should be this patch?
Good idea, I'm sending a separate patch to remove the comment.
Fam
Quoted 23 lines · Fam Zheng
At
system_reset, there is no point in retrying the queued request, because the driver that issued the request won't be around any more.Analyzed-by Laszlo Ersek <[email protected]>Reported-by Laszlo Ersek <[email protected]>Signed-off-by Fam Zheng <[email protected]>--- hw/block/virtio-blk.c | 6 ++++++ 1 file changed, 6 insertions(+)hw/block/virtio-blk.c +1
-0@@ -654,6 +654,7 @@ static void virtio_blk_reset(VirtIODevice *vdev) {VirtIOBlock *s =VIRTIO_BLK (vdev);AioContext *ctx; +VirtIOBlockReq *req;/* * This should cancel pending requests, but can't do nicely until there
hw/block/virtio-blk.c static void virtio_blk_reset(VirtIODevice *vdev) · line 670
Quoted 9 lines
hw/block/virtio-blk.c +5
-0@@ -661,6 +662,11 @@ static void virtio_blk_reset(VirtIODevice *vdev)*/ ctx =blk_get_aio_context (s->blk);aio_context_acquire (ctx); +while (s->rq) { + req = s->rq; + s->rq = req->next; +virtio_blk_free_request (req); + }blk_drain (s->blk);
blk_drain can consume requests too, so I think it should be the other way round: first drain, then drop any failed request that's been left in s->rq.
Paolo
Quoted 2 lines
hw/block/virtio-blk.c +0
-0if (s->dataplane) {
Quoted 23 lines · Paolo Bonzini
Quoted 20 lines · Fam Zheng
At
system_reset, there is no point in retrying the queued request, because the driver that issued the request won't be around any more.Analyzed-by Laszlo Ersek <[email protected]>Reported-by Laszlo Ersek <[email protected]>Signed-off-by Fam Zheng <[email protected]>--- hw/block/virtio-blk.c | 6 ++++++ 1 file changed, 6 insertions(+)hw/block/virtio-blk.c +1
-0@@ -654,6 +654,7 @@ static void virtio_blk_reset(VirtIODevice *vdev) {VirtIOBlock *s =VIRTIO_BLK (vdev);AioContext *ctx; +VirtIOBlockReq *req;
Quoted 16 lines
hw/block/virtio-blk.c static void virtio_blk_reset(VirtIODevice *vdev) · line 670
Quoted 12 lines
hw/block/virtio-blk.c +5
-0/* * This should cancel pending requests, but can't do nicely until there @@ -661,6 +662,11 @@ static void virtio_blk_reset(VirtIODevice *vdev)*/ ctx =blk_get_aio_context (s->blk);aio_context_acquire (ctx); +while (s->rq) { + req = s->rq; + s->rq = req->next; +virtio_blk_free_request (req); + }blk_drain (s->blk);
blk_draincan consume requests too, so I think it should be the other way round: first drain, then drop any failed request that's been left ins->rq.
I don't think there is any difference in this, blk_drain cannot trigger virtio_blk_dma_restart_cb, because it is only hooked to vm state change.
Fam
Quoted 41 lines · Fam Zheng
Quoted 23 lines · Paolo Bonzini
Quoted 20 lines · Fam Zheng
At
system_reset, there is no point in retrying the queued request, because the driver that issued the request won't be around any more.Analyzed-by Laszlo Ersek <[email protected]>Reported-by Laszlo Ersek <[email protected]>Signed-off-by Fam Zheng <[email protected]>--- hw/block/virtio-blk.c | 6 ++++++ 1 file changed, 6 insertions(+)hw/block/virtio-blk.c +1
-0@@ -654,6 +654,7 @@ static void virtio_blk_reset(VirtIODevice *vdev) {VirtIOBlock *s =VIRTIO_BLK (vdev);AioContext *ctx; +VirtIOBlockReq *req;Quoted 16 lines
hw/block/virtio-blk.c static void virtio_blk_reset(VirtIODevice *vdev) · line 670
Quoted 12 lines
hw/block/virtio-blk.c +5
-0/* * This should cancel pending requests, but can't do nicely until there @@ -661,6 +662,11 @@ static void virtio_blk_reset(VirtIODevice *vdev)*/ ctx =blk_get_aio_context (s->blk);aio_context_acquire (ctx); +while (s->rq) { + req = s->rq; + s->rq = req->next; +virtio_blk_free_request (req); + }blk_drain (s->blk);
blk_draincan consume requests too, so I think it should be the other way round: first drain, then drop any failed request that's been left ins->rq.
Quoted 2 lines
I don't think there is any difference in this,
blk_draincannot triggervirtio_blk_dma_restart_cb, because it is only hooked to vm state change.
Oh you mean that blk_drain can queue more requests to s->rq. That is a good point, indeed.
Fam