[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 29/33] nbd/client-connection: add option for non-blocking conn
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v3 29/33] nbd/client-connection: add option for non-blocking connection attempt |
Date: |
Fri, 16 Apr 2021 11:09:07 +0300 |
We'll need a possibility of non-blocking nbd_co_establish_connection(),
so that it returns immediately, and it returns success only if
connections was previously established in background.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
include/block/nbd.h | 2 +-
block/nbd.c | 2 +-
nbd/client-connection.c | 8 +++++++-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/include/block/nbd.h b/include/block/nbd.h
index 00bf08bade..6d5a807482 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -421,7 +421,7 @@ void nbd_client_connection_release(NBDClientConnection
*conn);
QIOChannel *coroutine_fn
nbd_co_establish_connection(NBDClientConnection *conn, NBDExportInfo *info,
- Error **errp);
+ bool blocking, Error **errp);
void coroutine_fn nbd_co_establish_connection_cancel(NBDClientConnection
*conn);
diff --git a/block/nbd.c b/block/nbd.c
index 59971bfba8..863d950abd 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -368,7 +368,7 @@ static int nbd_co_do_establish_connection(BlockDriverState
*bs, Error **errp)
assert(!s->ioc);
- s->ioc = nbd_co_establish_connection(s->conn, &s->info, errp);
+ s->ioc = nbd_co_establish_connection(s->conn, &s->info, true, errp);
if (!s->ioc) {
return -ECONNREFUSED;
}
diff --git a/nbd/client-connection.c b/nbd/client-connection.c
index 00efff293f..8914de7b94 100644
--- a/nbd/client-connection.c
+++ b/nbd/client-connection.c
@@ -251,6 +251,8 @@ void nbd_client_connection_release(NBDClientConnection
*conn)
* result, just return it now
* otherwise if thread is not running, start a thread and wait for completion
*
+ * If @blocking is false, don't wait for the thread, return immediately.
+ *
* If @info is not NULL, also do nbd-negotiation after successful connection.
* In this case info is used only as out parameter, and is fully initialized by
* nbd_co_establish_connection(). "IN" fields of info as well as related only
to
@@ -259,7 +261,7 @@ void nbd_client_connection_release(NBDClientConnection
*conn)
*/
QIOChannel *coroutine_fn
nbd_co_establish_connection(NBDClientConnection *conn, NBDExportInfo *info,
- Error **errp)
+ bool blocking, Error **errp)
{
QIOChannel *ioc;
QemuThread thread;
@@ -299,6 +301,10 @@ nbd_co_establish_connection(NBDClientConnection *conn,
NBDExportInfo *info,
connect_thread_func, conn,
QEMU_THREAD_DETACHED);
}
+ if (!blocking) {
+ return NULL;
+ }
+
conn->wait_co = qemu_coroutine_self();
}
--
2.29.2
- [PATCH v3 17/33] nbd/client-connection: implement connection retry, (continued)
- [PATCH v3 17/33] nbd/client-connection: implement connection retry, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 13/33] block/nbd: introduce nbd_client_connection_release(), Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 14/33] nbd: move connection code from block/nbd to nbd/client-connection, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 27/33] block/nbd: split nbd_co_do_establish_connection out of nbd_reconnect_attempt, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 18/33] nbd/client-connection: shutdown connection on release, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 24/33] block/nbd: drop BDRVNBDState::sioc, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 19/33] block/nbd: split nbd_handle_updated_info out of nbd_client_handshake(), Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 28/33] nbd/client-connection: do qio_channel_set_delay(false), Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 21/33] qemu-socket: pass monitor link to socket_get_fd directly, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 26/33] block-coroutine-wrapper: allow non bdrv_ prefix, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 29/33] nbd/client-connection: add option for non-blocking connection attempt,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v3 22/33] block/nbd: pass monitor directly to connection thread, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 30/33] block/nbd: reuse nbd_co_do_establish_connection() in nbd_open(), Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 20/33] block/nbd: use negotiation of NBDClientConnection, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 25/33] nbd/client-connection: return only one io channel, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 33/33] block/nbd: drop connection_co, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 32/33] block/nbd: safer transition to receiving request, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 31/33] block/nbd: add nbd_clinent_connected() helper, Vladimir Sementsov-Ogievskiy, 2021/04/16