qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] nbd/server: attach client channel to the export's AioContext
@ 2019-09-12 11:00 Sergio Lopez
  2019-09-20 12:38 ` Eric Blake
  2019-09-20 18:12 ` [Qemu-block] " John Snow
  0 siblings, 2 replies; 6+ messages in thread
From: Sergio Lopez @ 2019-09-12 11:00 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel, Sergio Lopez

On creation, the export's AioContext is set to the same one as the
BlockBackend, while the AioContext in the client QIOChannel is left
untouched.

As a result, when using data-plane, nbd_client_receive_next_request()
schedules coroutines in the IOThread AioContext, while the client's
QIOChannel is serviced from the main_loop, potentially triggering the
assertion at qio_channel_restart_[read|write].

To fix this, as soon we have the export corresponding to the client,
we call qio_channel_attach_aio_context() to attach the QIOChannel
context to the export's AioContext. This matches with the logic at
blk_aio_attached().

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1748253
Signed-off-by: Sergio Lopez <slp@redhat.com>
---
Changelog

v2:
 - Attach the channel once after negotiation completes, avoiding
   duplication. (thanks Kevin Wolf).
---
 nbd/server.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/nbd/server.c b/nbd/server.c
index 28c3c8be85..31d624e146 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1297,6 +1297,11 @@ static coroutine_fn int nbd_negotiate(NBDClient *client, Error **errp)
         return ret;
     }
 
+    /* Attach the channel to the same AioContext as the export */
+    if (client->exp && client->exp->ctx) {
+        qio_channel_attach_aio_context(client->ioc, client->exp->ctx);
+    }
+
     assert(!client->optlen);
     trace_nbd_negotiate_success();
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] nbd/server: attach client channel to the export's AioContext
  2019-09-12 11:00 [Qemu-devel] [PATCH v2] nbd/server: attach client channel to the export's AioContext Sergio Lopez
@ 2019-09-20 12:38 ` Eric Blake
  2019-09-20 18:12 ` [Qemu-block] " John Snow
  1 sibling, 0 replies; 6+ messages in thread
From: Eric Blake @ 2019-09-20 12:38 UTC (permalink / raw)
  To: Sergio Lopez, qemu-block; +Cc: kwolf, qemu-devel


[-- Attachment #1.1: Type: text/plain, Size: 1798 bytes --]

On 9/12/19 6:00 AM, Sergio Lopez wrote:
> On creation, the export's AioContext is set to the same one as the
> BlockBackend, while the AioContext in the client QIOChannel is left
> untouched.
> 
> As a result, when using data-plane, nbd_client_receive_next_request()
> schedules coroutines in the IOThread AioContext, while the client's
> QIOChannel is serviced from the main_loop, potentially triggering the
> assertion at qio_channel_restart_[read|write].
> 
> To fix this, as soon we have the export corresponding to the client,
> we call qio_channel_attach_aio_context() to attach the QIOChannel
> context to the export's AioContext. This matches with the logic at
> blk_aio_attached().
> 
> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1748253
> Signed-off-by: Sergio Lopez <slp@redhat.com>
> ---
> Changelog
> 
> v2:
>  - Attach the channel once after negotiation completes, avoiding
>    duplication. (thanks Kevin Wolf).
> ---
>  nbd/server.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/nbd/server.c b/nbd/server.c
> index 28c3c8be85..31d624e146 100644
> --- a/nbd/server.c
> +++ b/nbd/server.c
> @@ -1297,6 +1297,11 @@ static coroutine_fn int nbd_negotiate(NBDClient *client, Error **errp)
>          return ret;
>      }
>  
> +    /* Attach the channel to the same AioContext as the export */
> +    if (client->exp && client->exp->ctx) {
> +        qio_channel_attach_aio_context(client->ioc, client->exp->ctx);
> +    }
> +

Reviewed-by: Eric Blake <eblake@redhat.com>

Will queue through my NBD tree.

>      assert(!client->optlen);
>      trace_nbd_negotiate_success();
>  
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-block] [PATCH v2] nbd/server: attach client channel to the export's AioContext
  2019-09-12 11:00 [Qemu-devel] [PATCH v2] nbd/server: attach client channel to the export's AioContext Sergio Lopez
  2019-09-20 12:38 ` Eric Blake
@ 2019-09-20 18:12 ` John Snow
  2019-09-20 18:49   ` John Snow
  1 sibling, 1 reply; 6+ messages in thread
From: John Snow @ 2019-09-20 18:12 UTC (permalink / raw)
  To: Sergio Lopez, qemu-block; +Cc: kwolf, qemu-devel



On 9/12/19 7:00 AM, Sergio Lopez wrote:
> On creation, the export's AioContext is set to the same one as the
> BlockBackend, while the AioContext in the client QIOChannel is left
> untouched.
> 
> As a result, when using data-plane, nbd_client_receive_next_request()
> schedules coroutines in the IOThread AioContext, while the client's
> QIOChannel is serviced from the main_loop, potentially triggering the
> assertion at qio_channel_restart_[read|write].
> 
> To fix this, as soon we have the export corresponding to the client,
> we call qio_channel_attach_aio_context() to attach the QIOChannel
> context to the export's AioContext. This matches with the logic at
> blk_aio_attached().
> 
> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1748253
> Signed-off-by: Sergio Lopez <slp@redhat.com>
> ---
> Changelog
> 
> v2:
>  - Attach the channel once after negotiation completes, avoiding
>    duplication. (thanks Kevin Wolf).
> ---
>  nbd/server.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/nbd/server.c b/nbd/server.c
> index 28c3c8be85..31d624e146 100644
> --- a/nbd/server.c
> +++ b/nbd/server.c
> @@ -1297,6 +1297,11 @@ static coroutine_fn int nbd_negotiate(NBDClient *client, Error **errp)
>          return ret;
>      }
>  
> +    /* Attach the channel to the same AioContext as the export */
> +    if (client->exp && client->exp->ctx) {
> +        qio_channel_attach_aio_context(client->ioc, client->exp->ctx);
> +    }
> +
>      assert(!client->optlen);
>      trace_nbd_negotiate_success();
>  
> 

I assume this patch has been superseded by Eric's later patches?

--js


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-block] [PATCH v2] nbd/server: attach client channel to the export's AioContext
  2019-09-20 18:12 ` [Qemu-block] " John Snow
@ 2019-09-20 18:49   ` John Snow
  2019-09-20 19:11     ` Eric Blake
  0 siblings, 1 reply; 6+ messages in thread
From: John Snow @ 2019-09-20 18:49 UTC (permalink / raw)
  To: Sergio Lopez, qemu-block; +Cc: kwolf, qemu-devel



On 9/20/19 2:12 PM, John Snow wrote:
> 
> 
> On 9/12/19 7:00 AM, Sergio Lopez wrote:
>> On creation, the export's AioContext is set to the same one as the
>> BlockBackend, while the AioContext in the client QIOChannel is left
>> untouched.
>>
>> As a result, when using data-plane, nbd_client_receive_next_request()
>> schedules coroutines in the IOThread AioContext, while the client's
>> QIOChannel is serviced from the main_loop, potentially triggering the
>> assertion at qio_channel_restart_[read|write].
>>
>> To fix this, as soon we have the export corresponding to the client,
>> we call qio_channel_attach_aio_context() to attach the QIOChannel
>> context to the export's AioContext. This matches with the logic at
>> blk_aio_attached().
>>
>> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1748253
>> Signed-off-by: Sergio Lopez <slp@redhat.com>
>> ---
>> Changelog
>>
>> v2:
>>  - Attach the channel once after negotiation completes, avoiding
>>    duplication. (thanks Kevin Wolf).
>> ---
>>  nbd/server.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/nbd/server.c b/nbd/server.c
>> index 28c3c8be85..31d624e146 100644
>> --- a/nbd/server.c
>> +++ b/nbd/server.c
>> @@ -1297,6 +1297,11 @@ static coroutine_fn int nbd_negotiate(NBDClient *client, Error **errp)
>>          return ret;
>>      }
>>  
>> +    /* Attach the channel to the same AioContext as the export */
>> +    if (client->exp && client->exp->ctx) {
>> +        qio_channel_attach_aio_context(client->ioc, client->exp->ctx);
>> +    }
>> +
>>      assert(!client->optlen);
>>      trace_nbd_negotiate_success();
>>  
>>
> 
> I assume this patch has been superseded by Eric's later patches?

Nevermind -- my filtering got messed up slightly and I missed the
followup. I see that Eric staged this.

--js


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-block] [PATCH v2] nbd/server: attach client channel to the export's AioContext
  2019-09-20 18:49   ` John Snow
@ 2019-09-20 19:11     ` Eric Blake
  2019-09-20 22:03       ` Eric Blake
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Blake @ 2019-09-20 19:11 UTC (permalink / raw)
  To: John Snow, Sergio Lopez, qemu-block; +Cc: kwolf, qemu-devel


[-- Attachment #1.1: Type: text/plain, Size: 878 bytes --]

On 9/20/19 1:49 PM, John Snow wrote:
> 

>>> To fix this, as soon we have the export corresponding to the client,
>>> we call qio_channel_attach_aio_context() to attach the QIOChannel
>>> context to the export's AioContext. This matches with the logic at
>>> blk_aio_attached().
>>>

>>
>> I assume this patch has been superseded by Eric's later patches?
> 
> Nevermind -- my filtering got messed up slightly and I missed the
> followup. I see that Eric staged this.

I actually think both patches are needed: this one covers transactions,
while my later patch was on top of this to protect shutdown.  But now
you've made me curious; I'll see if my patch hoisted in front still
solves everything, or if we really do need both.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-block] [PATCH v2] nbd/server: attach client channel to the export's AioContext
  2019-09-20 19:11     ` Eric Blake
@ 2019-09-20 22:03       ` Eric Blake
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Blake @ 2019-09-20 22:03 UTC (permalink / raw)
  To: John Snow, Sergio Lopez, qemu-block; +Cc: kwolf, qemu-devel


[-- Attachment #1.1: Type: text/plain, Size: 1253 bytes --]

On 9/20/19 2:11 PM, Eric Blake wrote:
> On 9/20/19 1:49 PM, John Snow wrote:
>>
> 
>>>> To fix this, as soon we have the export corresponding to the client,
>>>> we call qio_channel_attach_aio_context() to attach the QIOChannel
>>>> context to the export's AioContext. This matches with the logic at
>>>> blk_aio_attached().
>>>>
> 
>>>
>>> I assume this patch has been superseded by Eric's later patches?
>>
>> Nevermind -- my filtering got messed up slightly and I missed the
>> followup. I see that Eric staged this.
> 
> I actually think both patches are needed: this one covers transactions,
> while my later patch was on top of this to protect shutdown.  But now
> you've made me curious; I'll see if my patch hoisted in front still
> solves everything, or if we really do need both.
> 

Nope, both patches are still needed.  Sergio's fixes the assertion:
    (qemu) qemu-kvm: io/channel.c:411: qio_channel_restart_read:
Assertion `qemu_get_current_aio_context() ==
qemu_coroutine_get_aio_context(co)' failed.

while mine fixes:
+qemu: qemu_mutex_unlock_impl: Operation not permitted


-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-09-20 22:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-12 11:00 [Qemu-devel] [PATCH v2] nbd/server: attach client channel to the export's AioContext Sergio Lopez
2019-09-20 12:38 ` Eric Blake
2019-09-20 18:12 ` [Qemu-block] " John Snow
2019-09-20 18:49   ` John Snow
2019-09-20 19:11     ` Eric Blake
2019-09-20 22:03       ` Eric Blake

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).