* [PATCH] virtio-blk: don't start dataplane during the stop of dataplane
@ 2023-10-11 7:17 lv.mengzhao
0 siblings, 0 replies; 5+ messages in thread
From: lv.mengzhao @ 2023-10-11 7:17 UTC (permalink / raw)
To: mst, stefanha, kwolf, hreitz; +Cc: qemu-block, qemu-devel, hu.jian
[-- Attachment #1.1.1: Type: text/plain, Size: 1675 bytes --]
From: hujian <hu.jian@zte.com.cn>
During the stop of dataplane for virtio-blk, virtio_bus_cleanup_host_notifier() is be
called to clean up notifier at the end, if polled ioeventfd, virtio_blk_handle_output()
is used to handle io request. But due to s->dataplane_disabled is false, it will be
returned directly, which drops io request.
Backtrace:
->virtio_blk_data_plane_stop
->virtio_bus_cleanup_host_notifier
->virtio_queue_host_notifier_read
->virtio_queue_notify_vq
->vq->handle_output
->virtio_blk_handle_output
->if (s->dataplane && !s->dataplane_stoped)
->if (!s->dataplane_disabled)
->return *
->virtio_blk_handle_output_do
The above problem can occur when using "virsh reset" cmdline to reset guest, while
guest does io.
To fix this problem, don't try to start dataplane if s->stopping is true, and io will
be handled by virtio_blk_handle_vq().
Signed-off-by: hujian <hu.jian@zte.com.cn>
---
hw/block/virtio-blk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 39e7f23..c2d5938 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -1166,7 +1166,7 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIOBlock *s = (VirtIOBlock *)vdev;
- if (s->dataplane && !s->dataplane_started) {
+ if (s->dataplane && !s->dataplane_started && !s->stopping) {
/* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start
* dataplane here instead of waiting for .set_status().
*/
--
1.8.3.1
[-- Attachment #1.1.2: Type: text/html , Size: 2685 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] virtio-blk: don't start dataplane during the stop of dataplane
2023-10-11 6:14 lv.mengzhao
2023-10-16 19:39 ` Stefan Hajnoczi
@ 2023-10-17 14:03 ` Stefan Hajnoczi
1 sibling, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2023-10-17 14:03 UTC (permalink / raw)
To: lv.mengzhao; +Cc: mst, kwolf, hreitz, qemu-devel, hu.jian
[-- Attachment #1: Type: text/plain, Size: 2229 bytes --]
On Wed, Oct 11, 2023 at 02:14:26PM +0800, lv.mengzhao@zte.com.cn wrote:
> From: hujian <hu.jian@zte.com.cn>
>
> During the stop of dataplane for virtio-blk, virtio_bus_cleanup_host_notifier() is be
> called to clean up notifier at the end, if polled ioeventfd, virtio_blk_handle_output()
> is used to handle io request. But due to s->dataplane_disabled is false, it will be
> returned directly, which drops io request.
> Backtrace:
> ->virtio_blk_data_plane_stop
> ->virtio_bus_cleanup_host_notifier
> ->virtio_queue_host_notifier_read
> ->virtio_queue_notify_vq
> ->vq->handle_output
> ->virtio_blk_handle_output
> ->if (s->dataplane && !s->dataplane_stoped)
> ->if (!s->dataplane_disabled)
> ->return *
> ->virtio_blk_handle_output_do
> The above problem can occur when using "virsh reset" cmdline to reset guest, while
> guest does io.
> To fix this problem, don't try to start dataplane if s->stopping is true, and io would
> be handled by virtio_blk_handle_vq().
>
> Signed-off-by: hujian <hu.jian@zte.com.cn>
> ---
> hw/block/virtio-blk.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
I have dropped this patch again after Fiona pointed out it does not
compile and Kevin noticed that handling requests from the main loop
thread while the I/O is still being processed in the IOThread is going
to cause thread-safety issues.
Can you explain the problem you are seeing in more detail? You run
"virsh reset" while the guest is doing I/O. Then what happens?
Stefan
>
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 39e7f23..c2d5938 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -1166,7 +1166,7 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
> {
> VirtIOBlock *s = (VirtIOBlock *)vdev;
>
> - if (s->dataplane && !s->dataplane_started) {
> + if (s->dataplane && !s->dataplane_started && !s->stopping) {
> /* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start
> * dataplane here instead of waiting for .set_status().
> */
> --
> 1.8.3.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] virtio-blk: don't start dataplane during the stop of dataplane
2023-10-11 6:14 lv.mengzhao
@ 2023-10-16 19:39 ` Stefan Hajnoczi
2023-10-17 14:03 ` Stefan Hajnoczi
1 sibling, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2023-10-16 19:39 UTC (permalink / raw)
To: lv.mengzhao; +Cc: mst, kwolf, hreitz, qemu-devel, hu.jian
[-- Attachment #1: Type: text/plain, Size: 1311 bytes --]
On Wed, Oct 11, 2023 at 02:14:26PM +0800, lv.mengzhao@zte.com.cn wrote:
> From: hujian <hu.jian@zte.com.cn>
>
> During the stop of dataplane for virtio-blk, virtio_bus_cleanup_host_notifier() is be
> called to clean up notifier at the end, if polled ioeventfd, virtio_blk_handle_output()
> is used to handle io request. But due to s->dataplane_disabled is false, it will be
> returned directly, which drops io request.
> Backtrace:
> ->virtio_blk_data_plane_stop
> ->virtio_bus_cleanup_host_notifier
> ->virtio_queue_host_notifier_read
> ->virtio_queue_notify_vq
> ->vq->handle_output
> ->virtio_blk_handle_output
> ->if (s->dataplane && !s->dataplane_stoped)
> ->if (!s->dataplane_disabled)
> ->return *
> ->virtio_blk_handle_output_do
> The above problem can occur when using "virsh reset" cmdline to reset guest, while
> guest does io.
> To fix this problem, don't try to start dataplane if s->stopping is true, and io would
> be handled by virtio_blk_handle_vq().
>
> Signed-off-by: hujian <hu.jian@zte.com.cn>
> ---
> hw/block/virtio-blk.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks, applied to my block tree:
https://gitlab.com/stefanha/qemu/commits/block
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] virtio-blk: don't start dataplane during the stop of dataplane
@ 2023-10-11 6:14 lv.mengzhao
2023-10-16 19:39 ` Stefan Hajnoczi
2023-10-17 14:03 ` Stefan Hajnoczi
0 siblings, 2 replies; 5+ messages in thread
From: lv.mengzhao @ 2023-10-11 6:14 UTC (permalink / raw)
To: mst, stefanha, kwolf, hreitz; +Cc: hreitz, qemu-devel, hu.jian
From: hujian <hu.jian@zte.com.cn>
During the stop of dataplane for virtio-blk, virtio_bus_cleanup_host_notifier() is be
called to clean up notifier at the end, if polled ioeventfd, virtio_blk_handle_output()
is used to handle io request. But due to s->dataplane_disabled is false, it will be
returned directly, which drops io request.
Backtrace:
->virtio_blk_data_plane_stop
->virtio_bus_cleanup_host_notifier
->virtio_queue_host_notifier_read
->virtio_queue_notify_vq
->vq->handle_output
->virtio_blk_handle_output
->if (s->dataplane && !s->dataplane_stoped)
->if (!s->dataplane_disabled)
->return *
->virtio_blk_handle_output_do
The above problem can occur when using "virsh reset" cmdline to reset guest, while
guest does io.
To fix this problem, don't try to start dataplane if s->stopping is true, and io would
be handled by virtio_blk_handle_vq().
Signed-off-by: hujian <hu.jian@zte.com.cn>
---
hw/block/virtio-blk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 39e7f23..c2d5938 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -1166,7 +1166,7 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIOBlock *s = (VirtIOBlock *)vdev;
- if (s->dataplane && !s->dataplane_started) {
+ if (s->dataplane && !s->dataplane_started && !s->stopping) {
/* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start
* dataplane here instead of waiting for .set_status().
*/
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] virtio-blk: don't start dataplane during the stop of dataplane
@ 2023-10-11 3:37 hujian
0 siblings, 0 replies; 5+ messages in thread
From: hujian @ 2023-10-11 3:37 UTC (permalink / raw)
To: mst, stefanha, kwolf, hreitz; +Cc: qemu-block, qemu-devel, hujian
During the stop of dataplane for virtio-blk, virtio_bus_cleanup_host_notifier() is be
called to clean up notifier at the end, if polled ioeventfd, virtio_blk_handle_output()
is used to handle io request. But due to s->dataplane_disabled is false, it will be
returned directly, which drops io request.
Backtrace:
->virtio_blk_data_plane_stop
->virtio_bus_cleanup_host_notifier
->virtio_queue_host_notifier_read
->virtio_queue_notify_vq
->vq->handle_output
->virtio_blk_handle_output
->if (s->dataplane && !s->dataplane_stoped)
->if (!s->dataplane_disabled)
->return *
->virtio_blk_handle_output_do
The above problem can occur when using "virsh reset" cmdline to reset guest, while
guest does io.
To fix this problem, don't try to start dataplane if s->stopping is true, and io would
be handled by virtio_blk_handle_vq().
Signed-off-by: hujian <hu.jian@zte.com.cn>
---
hw/block/virtio-blk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 39e7f23..c2d5938 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -1166,7 +1166,7 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIOBlock *s = (VirtIOBlock *)vdev;
- if (s->dataplane && !s->dataplane_started) {
+ if (s->dataplane && !s->dataplane_started && !s->stopping) {
/* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start
* dataplane here instead of waiting for .set_status().
*/
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-10-17 14:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-11 7:17 [PATCH] virtio-blk: don't start dataplane during the stop of dataplane lv.mengzhao
-- strict thread matches above, loose matches on Subject: below --
2023-10-11 6:14 lv.mengzhao
2023-10-16 19:39 ` Stefan Hajnoczi
2023-10-17 14:03 ` Stefan Hajnoczi
2023-10-11 3:37 hujian
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.