Re: [PATCH 03/14] block/nbd: drop unused NBDConnectThread::err field

2021-04-07 Thread Vladimir Sementsov-Ogievskiy

07.04.2021 14:42, Roman Kagan wrote:

On Wed, Apr 07, 2021 at 01:46:26PM +0300, Vladimir Sementsov-Ogievskiy wrote:

The field is used only to free it. Let's drop it for now for
simplicity.


Well, it's *now* (after your patch 2) only used to free it.  This makes
the reconnect process even further concealed from the user: the client
may be struggling to re-establish the connection but you'll never know
when looking at the logs.

As I wrote in my comment to patch 2 I believe these errors need to be
logged.  Whether to do it directly in the reconnection thread or punt it
to the spawner of it is another matter; I'd personally prefer to do
logging in the original bdrv context as it allows to (easier) tag the
log messages with the indication of which connection is suffering.



I see your point. It may be more reasonable to rebase my series on your patch 
and just save the err. Could you send your patch based on master?


--
Best regards,
Vladimir



Re: [PATCH 03/14] block/nbd: drop unused NBDConnectThread::err field

2021-04-07 Thread Roman Kagan
On Wed, Apr 07, 2021 at 01:46:26PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> The field is used only to free it. Let's drop it for now for
> simplicity.

Well, it's *now* (after your patch 2) only used to free it.  This makes
the reconnect process even further concealed from the user: the client
may be struggling to re-establish the connection but you'll never know
when looking at the logs.

As I wrote in my comment to patch 2 I believe these errors need to be
logged.  Whether to do it directly in the reconnection thread or punt it
to the spawner of it is another matter; I'd personally prefer to do
logging in the original bdrv context as it allows to (easier) tag the
log messages with the indication of which connection is suffering.

Thanks,
Roman.



[PATCH 03/14] block/nbd: drop unused NBDConnectThread::err field

2021-04-07 Thread Vladimir Sementsov-Ogievskiy
The field is used only to free it. Let's drop it for now for
simplicity.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
 block/nbd.c | 15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/block/nbd.c b/block/nbd.c
index 29c8bf..fbf5154048 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -94,12 +94,8 @@ typedef struct NBDConnectThread {
 QEMUBHFunc *bh_func;
 void *bh_opaque;
 
-/*
- * Result of last attempt. Valid in FAIL and SUCCESS states.
- * If you want to steal error, don't forget to set pointer to NULL.
- */
+/* Result of last attempt. Valid in FAIL and SUCCESS states. */
 QIOChannelSocket *sioc;
-Error *err;
 
 /* state and bh_ctx are protected by mutex */
 QemuMutex mutex;
@@ -385,7 +381,6 @@ static void nbd_free_connect_thread(NBDConnectThread *thr)
 if (thr->sioc) {
 qio_channel_close(QIO_CHANNEL(thr->sioc), NULL);
 }
-error_free(thr->err);
 qapi_free_SocketAddress(thr->saddr);
 g_free(thr);
 }
@@ -398,9 +393,7 @@ static void *connect_thread_func(void *opaque)
 
 thr->sioc = qio_channel_socket_new();
 
-error_free(thr->err);
-thr->err = NULL;
-ret = qio_channel_socket_connect_sync(thr->sioc, thr->saddr, &thr->err);
+ret = qio_channel_socket_connect_sync(thr->sioc, thr->saddr, NULL);
 if (ret < 0) {
 object_unref(OBJECT(thr->sioc));
 thr->sioc = NULL;
@@ -447,8 +440,6 @@ nbd_co_establish_connection(BlockDriverState *bs)
 switch (thr->state) {
 case CONNECT_THREAD_FAIL:
 case CONNECT_THREAD_NONE:
-error_free(thr->err);
-thr->err = NULL;
 thr->state = CONNECT_THREAD_RUNNING;
 qemu_thread_create(&thread, "nbd-connect",
connect_thread_func, thr, QEMU_THREAD_DETACHED);
@@ -491,8 +482,6 @@ nbd_co_establish_connection(BlockDriverState *bs)
 case CONNECT_THREAD_SUCCESS:
 case CONNECT_THREAD_FAIL:
 thr->state = CONNECT_THREAD_NONE;
-error_free(thr->err);
-thr->err = NULL;
 s->sioc = thr->sioc;
 thr->sioc = NULL;
 if (s->sioc) {
-- 
2.29.2