diff options
-rw-r--r-- | accel/tcg/cputlb.c | 4 | ||||
-rw-r--r-- | block/nbd-client.c | 33 |
2 files changed, 20 insertions, 17 deletions
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index e72415a882..bcbcc4db6c 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -765,7 +765,7 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, cpu->mem_io_vaddr = addr; - if (mr->global_locking) { + if (mr->global_locking && !qemu_mutex_iothread_locked()) { qemu_mutex_lock_iothread(); locked = true; } @@ -800,7 +800,7 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, cpu->mem_io_vaddr = addr; cpu->mem_io_pc = retaddr; - if (mr->global_locking) { + if (mr->global_locking && !qemu_mutex_iothread_locked()) { qemu_mutex_lock_iothread(); locked = true; } diff --git a/block/nbd-client.c b/block/nbd-client.c index cc05e73c2d..72651dcdb1 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -161,6 +161,8 @@ static int nbd_co_send_request(BlockDriverState *bs, NULL) < 0) { rc = -EIO; } + } else if (rc >= 0) { + rc = -EIO; } qio_channel_set_cork(s->ioc, false); } else { @@ -178,26 +180,27 @@ 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->ioc || s->quit) { + ret = -EIO; } else { - if (qiov && reply->error == 0) { + assert(s->reply.handle == request->handle); + 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 +220,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 +229,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 +236,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, |