aboutsummaryrefslogtreecommitdiff
path: root/block/nbd-client.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/nbd-client.c')
-rw-r--r--block/nbd-client.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/block/nbd-client.c b/block/nbd-client.c
index cc05e73c2d..5168a2cab6 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,