* [PATCH 8.0 regression] block/nfs: do not poll within a coroutine
@ 2023-04-12 11:26 Paolo Bonzini
2023-04-12 13:58 ` Peter Maydell
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Paolo Bonzini @ 2023-04-12 11:26 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, qemu-block
Since the former nfs_get_allocated_file_size is now a coroutine
function, it must suspend rather than poll. Switch BDRV_POLL_WHILE()
to a qemu_coroutine_yield() loop and schedule nfs_co_generic_bh_cb()
in place of the call to bdrv_wakeup().
Fixes: 82618d7bc341 ("block: Convert bdrv_get_allocated_file_size() to co_wrapper", 2023-02-01)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/nfs.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/block/nfs.c b/block/nfs.c
index 351dc6ec8d14..417defc0cfef 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -726,10 +726,8 @@ nfs_get_allocated_file_size_cb(int ret, struct nfs_context *nfs, void *data,
if (task->ret < 0) {
error_report("NFS Error: %s", nfs_get_error(nfs));
}
-
- /* Set task->complete before reading bs->wakeup. */
- qatomic_mb_set(&task->complete, 1);
- bdrv_wakeup(task->bs);
+ replay_bh_schedule_oneshot_event(task->client->aio_context,
+ nfs_co_generic_bh_cb, task);
}
static int64_t coroutine_fn nfs_co_get_allocated_file_size(BlockDriverState *bs)
@@ -743,15 +741,19 @@ static int64_t coroutine_fn nfs_co_get_allocated_file_size(BlockDriverState *bs)
return client->st_blocks * 512;
}
- task.bs = bs;
+ nfs_co_init_task(bs, &task);
task.st = &st;
- if (nfs_fstat_async(client->context, client->fh, nfs_get_allocated_file_size_cb,
- &task) != 0) {
- return -ENOMEM;
- }
+ WITH_QEMU_LOCK_GUARD(&client->mutex) {
+ if (nfs_fstat_async(client->context, client->fh, nfs_get_allocated_file_size_cb,
+ &task) != 0) {
+ return -ENOMEM;
+ }
- nfs_set_events(client);
- BDRV_POLL_WHILE(bs, !task.complete);
+ nfs_set_events(client);
+ }
+ while (!task.complete) {
+ qemu_coroutine_yield();
+ }
return (task.ret < 0 ? task.ret : st.st_blocks * 512);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 8.0 regression] block/nfs: do not poll within a coroutine
2023-04-12 11:26 [PATCH 8.0 regression] block/nfs: do not poll within a coroutine Paolo Bonzini
@ 2023-04-12 13:58 ` Peter Maydell
2023-04-12 15:08 ` Eric Blake
2023-04-12 15:18 ` Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2023-04-12 13:58 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, kwolf, qemu-block
If you would like this in 8.0 then it needs to be reviewed and in a pullreq
today...
thanks
-- PMM
On Wed, 12 Apr 2023 at 12:27, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> Since the former nfs_get_allocated_file_size is now a coroutine
> function, it must suspend rather than poll. Switch BDRV_POLL_WHILE()
> to a qemu_coroutine_yield() loop and schedule nfs_co_generic_bh_cb()
> in place of the call to bdrv_wakeup().
>
> Fixes: 82618d7bc341 ("block: Convert bdrv_get_allocated_file_size() to co_wrapper", 2023-02-01)
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> block/nfs.c | 24 +++++++++++++-----------
> 1 file changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/block/nfs.c b/block/nfs.c
> index 351dc6ec8d14..417defc0cfef 100644
> --- a/block/nfs.c
> +++ b/block/nfs.c
> @@ -726,10 +726,8 @@ nfs_get_allocated_file_size_cb(int ret, struct nfs_context *nfs, void *data,
> if (task->ret < 0) {
> error_report("NFS Error: %s", nfs_get_error(nfs));
> }
> -
> - /* Set task->complete before reading bs->wakeup. */
> - qatomic_mb_set(&task->complete, 1);
> - bdrv_wakeup(task->bs);
> + replay_bh_schedule_oneshot_event(task->client->aio_context,
> + nfs_co_generic_bh_cb, task);
> }
>
> static int64_t coroutine_fn nfs_co_get_allocated_file_size(BlockDriverState *bs)
> @@ -743,15 +741,19 @@ static int64_t coroutine_fn nfs_co_get_allocated_file_size(BlockDriverState *bs)
> return client->st_blocks * 512;
> }
>
> - task.bs = bs;
> + nfs_co_init_task(bs, &task);
> task.st = &st;
> - if (nfs_fstat_async(client->context, client->fh, nfs_get_allocated_file_size_cb,
> - &task) != 0) {
> - return -ENOMEM;
> - }
> + WITH_QEMU_LOCK_GUARD(&client->mutex) {
> + if (nfs_fstat_async(client->context, client->fh, nfs_get_allocated_file_size_cb,
> + &task) != 0) {
> + return -ENOMEM;
> + }
>
> - nfs_set_events(client);
> - BDRV_POLL_WHILE(bs, !task.complete);
> + nfs_set_events(client);
> + }
> + while (!task.complete) {
> + qemu_coroutine_yield();
> + }
>
> return (task.ret < 0 ? task.ret : st.st_blocks * 512);
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 8.0 regression] block/nfs: do not poll within a coroutine
2023-04-12 11:26 [PATCH 8.0 regression] block/nfs: do not poll within a coroutine Paolo Bonzini
2023-04-12 13:58 ` Peter Maydell
@ 2023-04-12 15:08 ` Eric Blake
2023-04-12 15:18 ` Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Eric Blake @ 2023-04-12 15:08 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, kwolf, qemu-block
On Wed, Apr 12, 2023 at 01:26:06PM +0200, Paolo Bonzini wrote:
> Since the former nfs_get_allocated_file_size is now a coroutine
> function, it must suspend rather than poll. Switch BDRV_POLL_WHILE()
> to a qemu_coroutine_yield() loop and schedule nfs_co_generic_bh_cb()
> in place of the call to bdrv_wakeup().
>
> Fixes: 82618d7bc341 ("block: Convert bdrv_get_allocated_file_size() to co_wrapper", 2023-02-01)
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> block/nfs.c | 24 +++++++++++++-----------
> 1 file changed, 13 insertions(+), 11 deletions(-)
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 8.0 regression] block/nfs: do not poll within a coroutine
2023-04-12 11:26 [PATCH 8.0 regression] block/nfs: do not poll within a coroutine Paolo Bonzini
2023-04-12 13:58 ` Peter Maydell
2023-04-12 15:08 ` Eric Blake
@ 2023-04-12 15:18 ` Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Kevin Wolf @ 2023-04-12 15:18 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, qemu-block
Am 12.04.2023 um 13:26 hat Paolo Bonzini geschrieben:
> Since the former nfs_get_allocated_file_size is now a coroutine
> function, it must suspend rather than poll. Switch BDRV_POLL_WHILE()
> to a qemu_coroutine_yield() loop and schedule nfs_co_generic_bh_cb()
> in place of the call to bdrv_wakeup().
>
> Fixes: 82618d7bc341 ("block: Convert bdrv_get_allocated_file_size() to co_wrapper", 2023-02-01)
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> block/nfs.c | 24 +++++++++++++-----------
> 1 file changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/block/nfs.c b/block/nfs.c
> index 351dc6ec8d14..417defc0cfef 100644
> --- a/block/nfs.c
> +++ b/block/nfs.c
> @@ -726,10 +726,8 @@ nfs_get_allocated_file_size_cb(int ret, struct nfs_context *nfs, void *data,
> if (task->ret < 0) {
> error_report("NFS Error: %s", nfs_get_error(nfs));
> }
> -
> - /* Set task->complete before reading bs->wakeup. */
> - qatomic_mb_set(&task->complete, 1);
> - bdrv_wakeup(task->bs);
> + replay_bh_schedule_oneshot_event(task->client->aio_context,
> + nfs_co_generic_bh_cb, task);
> }
>
> static int64_t coroutine_fn nfs_co_get_allocated_file_size(BlockDriverState *bs)
> @@ -743,15 +741,19 @@ static int64_t coroutine_fn nfs_co_get_allocated_file_size(BlockDriverState *bs)
> return client->st_blocks * 512;
> }
>
> - task.bs = bs;
> + nfs_co_init_task(bs, &task);
> task.st = &st;
> - if (nfs_fstat_async(client->context, client->fh, nfs_get_allocated_file_size_cb,
> - &task) != 0) {
> - return -ENOMEM;
> - }
> + WITH_QEMU_LOCK_GUARD(&client->mutex) {
> + if (nfs_fstat_async(client->context, client->fh, nfs_get_allocated_file_size_cb,
> + &task) != 0) {
> + return -ENOMEM;
> + }
>
> - nfs_set_events(client);
> - BDRV_POLL_WHILE(bs, !task.complete);
> + nfs_set_events(client);
Tab damage in this line.
> + }
> + while (!task.complete) {
> + qemu_coroutine_yield();
> + }
>
> return (task.ret < 0 ? task.ret : st.st_blocks * 512);
> }
With the indentation above fixed:
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-12 15:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-12 11:26 [PATCH 8.0 regression] block/nfs: do not poll within a coroutine Paolo Bonzini
2023-04-12 13:58 ` Peter Maydell
2023-04-12 15:08 ` Eric Blake
2023-04-12 15:18 ` Kevin Wolf
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).