[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 12/17] block/nbd-client: refactor nbd_co_request
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-block] [PATCH 12/17] block/nbd-client: refactor nbd_co_request |
Date: |
Fri, 4 Aug 2017 18:14:35 +0300 |
Reduce nesting, get rid of extra variable.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
block/nbd-client.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/block/nbd-client.c b/block/nbd-client.c
index b84cab4079..d6145c7db0 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -118,7 +118,6 @@ static int nbd_co_request(BlockDriverState *bs,
{
NBDClientSession *s = nbd_get_client_session(bs);
int rc, ret, i;
- NBDReply reply;
qemu_co_mutex_lock(&s->send_mutex);
while (s->in_flight == MAX_NBD_REQUESTS) {
@@ -171,20 +170,20 @@ static int nbd_co_request(BlockDriverState *bs,
/* Wait until we're woken up by nbd_read_reply_entry. */
qemu_coroutine_yield();
- reply = s->reply;
- if (reply.handle != request->handle ||
- !s->ioc) {
- reply.error = EIO;
- } else {
- if (qiov && reply.error == 0) {
- ret = nbd_rwv(s->ioc, qiov->iov, qiov->niov, request->len, true,
- NULL);
- if (ret != request->len) {
- reply.error = EIO;
- }
+ if (s->reply.handle != request->handle || !s->ioc) {
+ rc = -EIO;
+ goto out;
+ }
+
+ if (qiov && s->reply.error == 0) {
+ ret = nbd_rwv(s->ioc, qiov->iov, qiov->niov, request->len, true, NULL);
+ if (ret != request->len) {
+ rc = -EIO;
+ goto out;
}
}
- rc = -reply.error;
+
+ rc = -s->reply.error;
out:
/* Tell the read handler to read another header. */
--
2.11.1
- [Qemu-block] [PATCH 00/17] nbd client refactoring and fixing, Vladimir Sementsov-Ogievskiy, 2017/08/04
- [Qemu-block] [PATCH 12/17] block/nbd-client: refactor nbd_co_request,
Vladimir Sementsov-Ogievskiy <=
- [Qemu-block] [PATCH 14/17] block/nbd-client: exit reply-reading coroutine on incorrect handle, Vladimir Sementsov-Ogievskiy, 2017/08/04
- [Qemu-block] [PATCH 03/17] nbd/client: refactor nbd_receive_reply, Vladimir Sementsov-Ogievskiy, 2017/08/04
- [Qemu-block] [PATCH 16/17] block/nbd-client: drop reply field from NBDClientSession, Vladimir Sementsov-Ogievskiy, 2017/08/04
- [Qemu-block] [PATCH 17/17] block/nbd-client: always return EIO on and after the first io channel error, Vladimir Sementsov-Ogievskiy, 2017/08/04
- [Qemu-block] [PATCH 10/17] block/nbd-client: move nbd_coroutine_end content into nbd_co_request, Vladimir Sementsov-Ogievskiy, 2017/08/04
- [Qemu-block] [PATCH 13/17] block/nbd-client: refactor NBDClientSession.recv_coroutine, Vladimir Sementsov-Ogievskiy, 2017/08/04
- [Qemu-block] [PATCH 06/17] block/nbd-client: fix nbd_read_reply_entry, Vladimir Sementsov-Ogievskiy, 2017/08/04