diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2017-08-22 13:51:13 +0100 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2017-08-23 11:22:15 -0500 |
commit | 40f4a21895b5a7eae4011593837069f63460d983 (patch) | |
tree | cacbb56b00763fc9e0956df21ca11d742a77aa14 /block/nbd-client.h | |
parent | 12314f2d145c656f0a1f9aebcbe5e21be60c5ca5 (diff) |
nbd-client: avoid spurious qio_channel_yield() re-entry
The following scenario leads to an assertion failure in
qio_channel_yield():
1. Request coroutine calls qio_channel_yield() successfully when sending
would block on the socket. It is now yielded.
2. nbd_read_reply_entry() calls nbd_recv_coroutines_enter_all() because
nbd_receive_reply() failed.
3. Request coroutine is entered and returns from qio_channel_yield().
Note that the socket fd handler has not fired yet so
ioc->write_coroutine is still set.
4. Request coroutine attempts to send the request body with nbd_rwv()
but the socket would still block. qio_channel_yield() is called
again and assert(!ioc->write_coroutine) is hit.
The problem is that nbd_read_reply_entry() does not distinguish between
request coroutines that are waiting to receive a reply and those that
are not.
This patch adds a per-request bool receiving flag so
nbd_read_reply_entry() can avoid spurious aio_wake() calls.
Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20170822125113.5025-1-stefanha@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Tested-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block/nbd-client.h')
-rw-r--r-- | block/nbd-client.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/block/nbd-client.h b/block/nbd-client.h index 1935ffbcaa..b435754b82 100644 --- a/block/nbd-client.h +++ b/block/nbd-client.h @@ -17,6 +17,11 @@ #define MAX_NBD_REQUESTS 16 +typedef struct { + Coroutine *coroutine; + bool receiving; /* waiting for read_reply_co? */ +} NBDClientRequest; + typedef struct NBDClientSession { QIOChannelSocket *sioc; /* The master data channel */ QIOChannel *ioc; /* The current I/O channel which may differ (eg TLS) */ @@ -27,7 +32,7 @@ typedef struct NBDClientSession { Coroutine *read_reply_co; int in_flight; - Coroutine *recv_coroutine[MAX_NBD_REQUESTS]; + NBDClientRequest requests[MAX_NBD_REQUESTS]; NBDReply reply; bool quit; } NBDClientSession; |