qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] nbd: strict nbd_wr_syncv


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] nbd: strict nbd_wr_syncv
Date: Fri, 12 May 2017 17:46:18 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0


On 12/05/2017 16:17, Vladimir Sementsov-Ogievskiy wrote:
> nbd_wr_syncv is called either from coroutine or from client negotiation
> code, when socket is in blocking mode. So, -EAGAIN is impossible.
> 
> Furthermore, EAGAIN is confusing, as, what to read/write again? With
> EAGAIN as a return code we don't know how much data is already
> read or written by the function, so in case of EAGAIN the whole
> communication is broken.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
> ---
> 
> Hi all!
> 
> If I understand right, nbd_wr_syncv is called either from coroutine
> or from client negotiation code, when socket is in blocking mode.
> So, some thoughts
> 
> 1. let's establish this with an assert, because returning EAGAIN is
>    confusing (see above)

Yes, this seems like a good idea.

> 2. should we in case of non-coroutine context start this coroutine in 
>    nbd_wr_syncv, like in bdrv_prwv_co, and use non-blocking mode?
> 3. is there any problems or disadvantages of moving  client negotiation
>    to coroutine too?

When you move code to coroutines you need to be aware of what code can
now run concurrently, for example the monitor.  I'm not sure that it's
possible to do this.

Paolo

>  nbd/common.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/nbd/common.c b/nbd/common.c
> index dccbb8e9de..4db45b3ede 100644
> --- a/nbd/common.c
> +++ b/nbd/common.c
> @@ -20,6 +20,10 @@
>  #include "qapi/error.h"
>  #include "nbd-internal.h"
>  
> +/* nbd_wr_syncv
> + * The function may be called from coroutine or from non-coroutine context.
> + * When called from non-coroutine context @ioc must be in blocking mode.
> + */
>  ssize_t nbd_wr_syncv(QIOChannel *ioc,
>                       struct iovec *iov,
>                       size_t niov,
> @@ -42,11 +46,8 @@ ssize_t nbd_wr_syncv(QIOChannel *ioc,
>              len = qio_channel_writev(ioc, local_iov, nlocal_iov, &local_err);
>          }
>          if (len == QIO_CHANNEL_ERR_BLOCK) {
> -            if (qemu_in_coroutine()) {
> -                qio_channel_yield(ioc, do_read ? G_IO_IN : G_IO_OUT);
> -            } else {
> -                return -EAGAIN;
> -            }
> +            assert(qemu_in_coroutine());
> +            qio_channel_yield(ioc, do_read ? G_IO_IN : G_IO_OUT);
>              continue;
>          }
>          if (len < 0) {
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]