[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/14] block/nbd: refactor nbd_co_establish_connection
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH 12/14] block/nbd: refactor nbd_co_establish_connection |
Date: |
Wed, 7 Apr 2021 13:46:35 +0300 |
We are going to drop nbd connect thread states for simplicity. This is
a step that makes further commit simpler.
Note, that yank_* calls moved out of thr->mutex. They shouldn't be
related and already called from other places in the file not under the
mutex.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
block/nbd.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/block/nbd.c b/block/nbd.c
index 6729561935..f0319d2256 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -413,7 +413,6 @@ static void connect_thread_cb(QIOChannelSocket *sioc, int
ret, void *opaque)
static int coroutine_fn
nbd_co_establish_connection(BlockDriverState *bs)
{
- int ret;
BDRVNBDState *s = bs->opaque;
NBDConnectCB *thr = s->connect_thread;
@@ -430,10 +429,7 @@ nbd_co_establish_connection(BlockDriverState *bs)
thr->state = CONNECT_THREAD_NONE;
s->sioc = thr->sioc;
thr->sioc = NULL;
- yank_register_function(BLOCKDEV_YANK_INSTANCE(bs->node_name),
- nbd_yank, bs);
- qemu_mutex_unlock(&thr->mutex);
- return 0;
+ goto out;
case CONNECT_THREAD_RUNNING:
/* Already running, will wait */
break;
@@ -459,11 +455,6 @@ nbd_co_establish_connection(BlockDriverState *bs)
thr->state = CONNECT_THREAD_NONE;
s->sioc = thr->sioc;
thr->sioc = NULL;
- if (s->sioc) {
- yank_register_function(BLOCKDEV_YANK_INSTANCE(bs->node_name),
- nbd_yank, bs);
- }
- ret = (s->sioc ? 0 : -1);
break;
case CONNECT_THREAD_RUNNING:
case CONNECT_THREAD_RUNNING_DETACHED:
@@ -472,7 +463,6 @@ nbd_co_establish_connection(BlockDriverState *bs)
* failed. Still connect thread is executing in background, and its
* result may be used for next connection attempt.
*/
- ret = -1;
break;
case CONNECT_THREAD_NONE:
@@ -486,9 +476,15 @@ nbd_co_establish_connection(BlockDriverState *bs)
abort();
}
+out:
qemu_mutex_unlock(&thr->mutex);
- return ret;
+ if (s->sioc) {
+ yank_register_function(BLOCKDEV_YANK_INSTANCE(bs->node_name),
+ nbd_yank, bs);
+ }
+
+ return s->sioc ? 0 : -1;
}
/*
--
2.29.2
- [PATCH 06/14] block/nbd: further segregation of connect-thread, (continued)
- [PATCH 06/14] block/nbd: further segregation of connect-thread, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 02/14] block/nbd: nbd_co_establish_connection(): drop unused errp, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 05/14] block/nbd: rename NBDConnectThread to NBDConnectCB, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 08/14] block/nbd: move nbd connect-thread to nbd/client-connect.c, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 07/14] block/nbd: drop nbd_free_connect_thread(), Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 09/14] block/nbd: NBDConnectCB: drop bh_* fields, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 10/14] block/nbd: move wait_connect field under mutex protection, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 11/14] block/nbd: refactor connect_bh(), Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 12/14] block/nbd: refactor nbd_co_establish_connection,
Vladimir Sementsov-Ogievskiy <=
- [PATCH 13/14] block/nbd: nbd_co_establish_connection_cancel(): rename wake to do_wake, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 14/14] block/nbd: drop thr->state, Vladimir Sementsov-Ogievskiy, 2021/04/07
- DROP THIS Re: [PATCH 00/14] nbd: move reconnect-thread to separate file, Vladimir Sementsov-Ogievskiy, 2021/04/08