diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 2017-09-20 15:45:05 +0300 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2017-09-25 08:21:25 -0500 |
commit | 319a56cde7313ca42a72e0a145ffa8e7832ada86 (patch) | |
tree | 1f97086d0964c47eaead3efe42eba33e97d42509 /block | |
parent | cfa3ad635c6d12f98049a7598e23305d233a4d73 (diff) | |
download | qemu-319a56cde7313ca42a72e0a145ffa8e7832ada86.zip qemu-319a56cde7313ca42a72e0a145ffa8e7832ada86.tar.gz qemu-319a56cde7313ca42a72e0a145ffa8e7832ada86.tar.bz2 |
block/nbd-client: refactor nbd_co_receive_reply
"NBDReply *reply" parameter of nbd_co_receive_reply is used only
to pass return value for nbd_co_request (reply.error). Remove it
and use function return value instead.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20170920124507.18841-2-vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/nbd-client.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/block/nbd-client.c b/block/nbd-client.c index cc05e73..5168a2c 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -178,26 +178,26 @@ err: return rc; } -static void nbd_co_receive_reply(NBDClientSession *s, - NBDRequest *request, - NBDReply *reply, - QEMUIOVector *qiov) +static int nbd_co_receive_reply(NBDClientSession *s, + NBDRequest *request, + QEMUIOVector *qiov) { + int ret; int i = HANDLE_TO_INDEX(s, request->handle); /* Wait until we're woken up by nbd_read_reply_entry. */ s->requests[i].receiving = true; qemu_coroutine_yield(); s->requests[i].receiving = false; - *reply = s->reply; - if (reply->handle != request->handle || !s->ioc || s->quit) { - reply->error = EIO; + if (s->reply.handle != request->handle || !s->ioc || s->quit) { + ret = -EIO; } else { - if (qiov && reply->error == 0) { + ret = -s->reply.error; + if (qiov && s->reply.error == 0) { assert(request->len == iov_size(qiov->iov, qiov->niov)); if (qio_channel_readv_all(s->ioc, qiov->iov, qiov->niov, NULL) < 0) { - reply->error = EIO; + ret = -EIO; s->quit = true; } } @@ -217,6 +217,8 @@ static void nbd_co_receive_reply(NBDClientSession *s, s->in_flight--; qemu_co_queue_next(&s->free_sema); qemu_co_mutex_unlock(&s->send_mutex); + + return ret; } static int nbd_co_request(BlockDriverState *bs, @@ -224,7 +226,6 @@ static int nbd_co_request(BlockDriverState *bs, QEMUIOVector *qiov) { NBDClientSession *client = nbd_get_client_session(bs); - NBDReply reply; int ret; assert(!qiov || request->type == NBD_CMD_WRITE || @@ -232,12 +233,11 @@ static int nbd_co_request(BlockDriverState *bs, ret = nbd_co_send_request(bs, request, request->type == NBD_CMD_WRITE ? qiov : NULL); if (ret < 0) { - reply.error = -ret; - } else { - nbd_co_receive_reply(client, request, &reply, - request->type == NBD_CMD_READ ? qiov : NULL); + return ret; } - return -reply.error; + + return nbd_co_receive_reply(client, request, + request->type == NBD_CMD_READ ? qiov : NULL); } int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset, |