]>
Commit | Line | Data |
---|---|---|
b45e13fe | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
b45e13fe | 2 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
507c6de3 WB |
3 | Date: Tue, 16 May 2017 12:45:29 +0300 |
4 | Subject: [PATCH] nbd: strict nbd_wr_syncv | |
b45e13fe AD |
5 | |
6 | nbd_wr_syncv is called either from coroutine or from client negotiation | |
7 | code, when socket is in blocking mode. So, -EAGAIN is impossible. | |
8 | ||
9 | Furthermore, EAGAIN is confusing, as, what to read/write again? With | |
10 | EAGAIN as a return code we don't know how much data is already | |
11 | read or written by the function, so in case of EAGAIN the whole | |
12 | communication is broken. | |
13 | ||
14 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | |
15 | Message-Id: <20170516094533.6160-2-vsementsov@virtuozzo.com> | |
16 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | |
b45e13fe AD |
17 | --- |
18 | nbd/common.c | 11 ++++++----- | |
19 | 1 file changed, 6 insertions(+), 5 deletions(-) | |
20 | ||
21 | diff --git a/nbd/common.c b/nbd/common.c | |
507c6de3 | 22 | index dccbb8e9de..4db45b3ede 100644 |
b45e13fe AD |
23 | --- a/nbd/common.c |
24 | +++ b/nbd/common.c | |
25 | @@ -20,6 +20,10 @@ | |
26 | #include "qapi/error.h" | |
27 | #include "nbd-internal.h" | |
28 | ||
29 | +/* nbd_wr_syncv | |
30 | + * The function may be called from coroutine or from non-coroutine context. | |
31 | + * When called from non-coroutine context @ioc must be in blocking mode. | |
32 | + */ | |
33 | ssize_t nbd_wr_syncv(QIOChannel *ioc, | |
34 | struct iovec *iov, | |
35 | size_t niov, | |
36 | @@ -42,11 +46,8 @@ ssize_t nbd_wr_syncv(QIOChannel *ioc, | |
37 | len = qio_channel_writev(ioc, local_iov, nlocal_iov, &local_err); | |
38 | } | |
39 | if (len == QIO_CHANNEL_ERR_BLOCK) { | |
40 | - if (qemu_in_coroutine()) { | |
41 | - qio_channel_yield(ioc, do_read ? G_IO_IN : G_IO_OUT); | |
42 | - } else { | |
43 | - return -EAGAIN; | |
44 | - } | |
45 | + assert(qemu_in_coroutine()); | |
46 | + qio_channel_yield(ioc, do_read ? G_IO_IN : G_IO_OUT); | |
47 | continue; | |
48 | } | |
49 | if (len < 0) { | |
50 | -- | |
507c6de3 | 51 | 2.11.0 |
b45e13fe | 52 |