* [Qemu-devel] [PATCH v2 0/3] nbd-client: drop extra error noise
@ 2018-12-18 22:57 Eric Blake
2018-12-18 22:57 ` [Qemu-devel] [PATCH v2 1/3] nbd: publish _lookup functions Eric Blake
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Eric Blake @ 2018-12-18 22:57 UTC (permalink / raw)
To: qemu-devel; +Cc: vsementsov
This is a counter-proposal to Vladimir's initial post for
reducing the noise in iotest 083. The difference is that
I dropped error_get_hint, since I couldn't find any useful
hint to be traced during transmission phase in the first place,
and instead added a trace message for the one place where we
do set hints during handshaking phase.
Eric Blake (1):
nbd/client: Trace all server option error messages
Vladimir Sementsov-Ogievskiy (2):
nbd: publish _lookup functions
block/nbd-client: use traces instead of noisy error_report_err
include/block/nbd.h | 5 +++++
nbd/nbd-internal.h | 5 -----
block/nbd-client.c | 23 +++++++++++++++++++----
nbd/client.c | 2 ++
block/trace-events | 4 ++++
nbd/trace-events | 1 +
tests/qemu-iotests/083.out | 28 ----------------------------
7 files changed, 31 insertions(+), 37 deletions(-)
--
2.17.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2 1/3] nbd: publish _lookup functions
2018-12-18 22:57 [Qemu-devel] [PATCH v2 0/3] nbd-client: drop extra error noise Eric Blake
@ 2018-12-18 22:57 ` Eric Blake
2018-12-18 22:57 ` [Qemu-devel] [PATCH v2 2/3] nbd/client: Trace all server option error messages Eric Blake
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2018-12-18 22:57 UTC (permalink / raw)
To: qemu-devel
Cc: vsementsov, Kevin Wolf, Max Reitz, open list:Network Block Dev...
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
These functions are used for formatting pretty trace points. We are
going to add some in block/nbd-client, so, let's publish all these
functions at once. Note, that nbd_reply_type_lookup is already
published, and constants, "named" by these functions live in
include/block/nbd.h too.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20181102151152.288399-3-vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
include/block/nbd.h | 5 +++++
nbd/nbd-internal.h | 5 -----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/block/nbd.h b/include/block/nbd.h
index 6a5bfe5d559..65402d33964 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -343,5 +343,10 @@ static inline bool nbd_reply_is_structured(NBDReply *reply)
}
const char *nbd_reply_type_lookup(uint16_t type);
+const char *nbd_opt_lookup(uint32_t opt);
+const char *nbd_rep_lookup(uint32_t rep);
+const char *nbd_info_lookup(uint16_t info);
+const char *nbd_cmd_lookup(uint16_t info);
+const char *nbd_err_lookup(int err);
#endif
diff --git a/nbd/nbd-internal.h b/nbd/nbd-internal.h
index eeff78d3c98..f38be9ebaaf 100644
--- a/nbd/nbd-internal.h
+++ b/nbd/nbd-internal.h
@@ -100,11 +100,6 @@ struct NBDTLSHandshakeData {
void nbd_tls_handshake(QIOTask *task,
void *opaque);
-const char *nbd_opt_lookup(uint32_t opt);
-const char *nbd_rep_lookup(uint32_t rep);
-const char *nbd_info_lookup(uint16_t info);
-const char *nbd_cmd_lookup(uint16_t info);
-const char *nbd_err_lookup(int err);
int nbd_drop(QIOChannel *ioc, size_t size, Error **errp);
--
2.17.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2 2/3] nbd/client: Trace all server option error messages
2018-12-18 22:57 [Qemu-devel] [PATCH v2 0/3] nbd-client: drop extra error noise Eric Blake
2018-12-18 22:57 ` [Qemu-devel] [PATCH v2 1/3] nbd: publish _lookup functions Eric Blake
@ 2018-12-18 22:57 ` Eric Blake
2018-12-19 11:41 ` Vladimir Sementsov-Ogievskiy
2018-12-18 22:57 ` [Qemu-devel] [PATCH v2 3/3] block/nbd-client: use traces instead of noisy error_report_err Eric Blake
2018-12-19 12:03 ` [Qemu-devel] [PATCH v2 0/3] nbd-client: drop extra error noise Vladimir Sementsov-Ogievskiy
3 siblings, 1 reply; 7+ messages in thread
From: Eric Blake @ 2018-12-18 22:57 UTC (permalink / raw)
To: qemu-devel; +Cc: vsementsov, open list:Network Block Dev...
Not all servers send free-form text alongside option error replies, but
for servers that do (such as qemu), we pass the server's message as a
hint alongside our own error reporting. However, it would also be
useful to trace such server messages, since we can't guarantee how the
hint may be consumed.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
nbd/client.c | 2 ++
nbd/trace-events | 1 +
2 files changed, 3 insertions(+)
diff --git a/nbd/client.c b/nbd/client.c
index b4d457a19ad..0ad7147ed95 100644
--- a/nbd/client.c
+++ b/nbd/client.c
@@ -171,6 +171,8 @@ static int nbd_handle_reply_err(QIOChannel *ioc, NBDOptionReply *reply,
goto cleanup;
}
msg[reply->length] = '\0';
+ trace_nbd_server_error_msg(reply->type,
+ nbd_reply_type_lookup(reply->type), msg);
}
switch (reply->type) {
diff --git a/nbd/trace-events b/nbd/trace-events
index 5e1d4afe8e6..5492042acbf 100644
--- a/nbd/trace-events
+++ b/nbd/trace-events
@@ -1,6 +1,7 @@
# nbd/client.c
nbd_send_option_request(uint32_t opt, const char *name, uint32_t len) "Sending option request %" PRIu32" (%s), len %" PRIu32
nbd_receive_option_reply(uint32_t option, const char *optname, uint32_t type, const char *typename, uint32_t length) "Received option reply %" PRIu32" (%s), type %" PRIu32" (%s), len %" PRIu32
+nbd_server_error_msg(uint32_t err, const char *type, const char *msg) "server reported error 0x%" PRIx32 " (%s) with additional message: %s"
nbd_reply_err_unsup(uint32_t option, const char *name) "server doesn't understand request %" PRIu32 " (%s), attempting fallback"
nbd_opt_go_start(const char *name) "Attempting NBD_OPT_GO for export '%s'"
nbd_opt_go_success(void) "Export is good to go"
--
2.17.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2 3/3] block/nbd-client: use traces instead of noisy error_report_err
2018-12-18 22:57 [Qemu-devel] [PATCH v2 0/3] nbd-client: drop extra error noise Eric Blake
2018-12-18 22:57 ` [Qemu-devel] [PATCH v2 1/3] nbd: publish _lookup functions Eric Blake
2018-12-18 22:57 ` [Qemu-devel] [PATCH v2 2/3] nbd/client: Trace all server option error messages Eric Blake
@ 2018-12-18 22:57 ` Eric Blake
2018-12-19 12:03 ` [Qemu-devel] [PATCH v2 0/3] nbd-client: drop extra error noise Vladimir Sementsov-Ogievskiy
3 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2018-12-18 22:57 UTC (permalink / raw)
To: qemu-devel
Cc: vsementsov, Kevin Wolf, Max Reitz, open list:Network Block Dev...
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reduce extra noise of nbd-client, change 083 correspondingly.
In various commits (be41c100 in 2.10, f140e300 in 2.11, 78a33ab
in 2.12), we added spots where qemu as an NBD client would report
problems communicating with the server to stderr, because there
was no where else to send the error to. However, this is racy,
particularly since the most common source of these errors is when
either the client or the server abruptly hangs up, leaving one
coroutine to report the error only if it wins (or loses) the
race as attempting the read from the server before another
thread completes its cleanup of a protocol error that caused the
disconnect in the first place. The race is also apparent in the
fact that differences in the flush behavior of the server can
alter the frequency of encountering the race in the client (see
commit 6d39db96).
Rather than polluting stderr, it's better to just trace these
situations, for use by developers debugging a flaky connection,
particularly since the real error that either triggers the abrupt
disconnection in the first place, or that results from the EIO
when a request can't receive a reply, DOES make it back to the
user in the normal Error propagation channels.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20181102151152.288399-4-vsementsov@virtuozzo.com>
[eblake: drop depedence on error hint, enhance commit message]
Signed-off-by: Eric Blake <eblake@redhat.com>
---
block/nbd-client.c | 23 +++++++++++++++++++----
block/trace-events | 4 ++++
tests/qemu-iotests/083.out | 28 ----------------------------
3 files changed, 23 insertions(+), 32 deletions(-)
diff --git a/block/nbd-client.c b/block/nbd-client.c
index fc5b7eda8ee..ef320759716 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -28,6 +28,8 @@
*/
#include "qemu/osdep.h"
+
+#include "trace.h"
#include "qapi/error.h"
#include "nbd-client.h"
@@ -79,7 +81,8 @@ static coroutine_fn void nbd_read_reply_entry(void *opaque)
assert(s->reply.handle == 0);
ret = nbd_receive_reply(s->ioc, &s->reply, &local_err);
if (local_err) {
- error_report_err(local_err);
+ trace_nbd_read_reply_entry_fail(ret, error_get_pretty(local_err));
+ error_free(local_err);
}
if (ret <= 0) {
break;
@@ -771,7 +774,11 @@ static int nbd_co_request(BlockDriverState *bs, NBDRequest *request,
ret = nbd_co_receive_return_code(client, request->handle, &local_err);
if (local_err) {
- error_report_err(local_err);
+ trace_nbd_co_request_fail(request->from, request->len, request->handle,
+ request->flags, request->type,
+ nbd_cmd_lookup(request->type),
+ ret, error_get_pretty(local_err));
+ error_free(local_err);
}
return ret;
}
@@ -802,7 +809,11 @@ int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset,
ret = nbd_co_receive_cmdread_reply(client, request.handle, offset, qiov,
&local_err);
if (local_err) {
- error_report_err(local_err);
+ trace_nbd_co_request_fail(request.from, request.len, request.handle,
+ request.flags, request.type,
+ nbd_cmd_lookup(request.type),
+ ret, error_get_pretty(local_err));
+ error_free(local_err);
}
return ret;
}
@@ -925,7 +936,11 @@ int coroutine_fn nbd_client_co_block_status(BlockDriverState *bs,
ret = nbd_co_receive_blockstatus_reply(client, request.handle, bytes,
&extent, &local_err);
if (local_err) {
- error_report_err(local_err);
+ trace_nbd_co_request_fail(request.from, request.len, request.handle,
+ request.flags, request.type,
+ nbd_cmd_lookup(request.type),
+ ret, error_get_pretty(local_err));
+ error_free(local_err);
}
if (ret < 0) {
return ret;
diff --git a/block/trace-events b/block/trace-events
index 3e8c47bb243..693c14c4435 100644
--- a/block/trace-events
+++ b/block/trace-events
@@ -156,3 +156,7 @@ nvme_cmd_map_qiov_iov(void *s, int i, void *page, int pages) "s %p iov[%d] %p pa
# block/iscsi.c
iscsi_xcopy(void *src_lun, uint64_t src_off, void *dst_lun, uint64_t dst_off, uint64_t bytes, int ret) "src_lun %p offset %"PRIu64" dst_lun %p offset %"PRIu64" bytes %"PRIu64" ret %d"
+
+# block/nbd-client.c
+nbd_read_reply_entry_fail(int ret, const char *err) "ret = %d, err: %s"
+nbd_co_request_fail(uint64_t from, uint32_t len, uint64_t handle, uint16_t flags, uint16_t type, const char *name, int ret, const char *err) "Request failed { .from = %" PRIu64", .len = %" PRIu32 ", .handle = %" PRIu64 ", .flags = 0x%" PRIx16 ", .type = %" PRIu16 " (%s) } ret = %d, err: %s"
diff --git a/tests/qemu-iotests/083.out b/tests/qemu-iotests/083.out
index f9af8bb6918..7419722cd7a 100644
--- a/tests/qemu-iotests/083.out
+++ b/tests/qemu-iotests/083.out
@@ -41,8 +41,6 @@ can't open device nbd+tcp://127.0.0.1:PORT/foo
=== Check disconnect after neg2 ===
-Unable to read from socket: Connection reset by peer
-Connection closed
read failed: Input/output error
=== Check disconnect 8 neg2 ===
@@ -55,40 +53,30 @@ can't open device nbd+tcp://127.0.0.1:PORT/foo
=== Check disconnect before request ===
-Unable to read from socket: Connection reset by peer
-Connection closed
read failed: Input/output error
=== Check disconnect after request ===
-Connection closed
read failed: Input/output error
=== Check disconnect before reply ===
-Connection closed
read failed: Input/output error
=== Check disconnect after reply ===
-Unexpected end-of-file before all bytes were read
read failed: Input/output error
=== Check disconnect 4 reply ===
-Unexpected end-of-file before all bytes were read
-Connection closed
read failed: Input/output error
=== Check disconnect 8 reply ===
-Unexpected end-of-file before all bytes were read
-Connection closed
read failed: Input/output error
=== Check disconnect before data ===
-Unexpected end-of-file before all bytes were read
read failed: Input/output error
=== Check disconnect after data ===
@@ -118,8 +106,6 @@ can't open device nbd+tcp://127.0.0.1:PORT/
=== Check disconnect after neg-classic ===
-Unable to read from socket: Connection reset by peer
-Connection closed
read failed: Input/output error
=== Check disconnect before neg1 ===
@@ -164,8 +150,6 @@ can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock
=== Check disconnect after neg2 ===
-Unable to read from socket: Connection reset by peer
-Connection closed
read failed: Input/output error
=== Check disconnect 8 neg2 ===
@@ -178,40 +162,30 @@ can't open device nbd+unix:///foo?socket=TEST_DIR/nbd.sock
=== Check disconnect before request ===
-Unable to read from socket: Connection reset by peer
-Connection closed
read failed: Input/output error
=== Check disconnect after request ===
-Connection closed
read failed: Input/output error
=== Check disconnect before reply ===
-Connection closed
read failed: Input/output error
=== Check disconnect after reply ===
-Unexpected end-of-file before all bytes were read
read failed: Input/output error
=== Check disconnect 4 reply ===
-Unexpected end-of-file before all bytes were read
-Connection closed
read failed: Input/output error
=== Check disconnect 8 reply ===
-Unexpected end-of-file before all bytes were read
-Connection closed
read failed: Input/output error
=== Check disconnect before data ===
-Unexpected end-of-file before all bytes were read
read failed: Input/output error
=== Check disconnect after data ===
@@ -241,8 +215,6 @@ can't open device nbd+unix:///?socket=TEST_DIR/nbd.sock
=== Check disconnect after neg-classic ===
-Unable to read from socket: Connection reset by peer
-Connection closed
read failed: Input/output error
*** done
--
2.17.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v2 2/3] nbd/client: Trace all server option error messages
2018-12-18 22:57 ` [Qemu-devel] [PATCH v2 2/3] nbd/client: Trace all server option error messages Eric Blake
@ 2018-12-19 11:41 ` Vladimir Sementsov-Ogievskiy
0 siblings, 0 replies; 7+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2018-12-19 11:41 UTC (permalink / raw)
To: Eric Blake, qemu-devel@nongnu.org; +Cc: open list:Network Block Dev...
19.12.2018 1:57, Eric Blake wrote:
> Not all servers send free-form text alongside option error replies, but
> for servers that do (such as qemu), we pass the server's message as a
> hint alongside our own error reporting. However, it would also be
> useful to trace such server messages, since we can't guarantee how the
> hint may be consumed.
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
> nbd/client.c | 2 ++
> nbd/trace-events | 1 +
> 2 files changed, 3 insertions(+)
>
> diff --git a/nbd/client.c b/nbd/client.c
> index b4d457a19ad..0ad7147ed95 100644
> --- a/nbd/client.c
> +++ b/nbd/client.c
> @@ -171,6 +171,8 @@ static int nbd_handle_reply_err(QIOChannel *ioc, NBDOptionReply *reply,
> goto cleanup;
> }
> msg[reply->length] = '\0';
> + trace_nbd_server_error_msg(reply->type,
> + nbd_reply_type_lookup(reply->type), msg);
> }
>
> switch (reply->type) {
> diff --git a/nbd/trace-events b/nbd/trace-events
> index 5e1d4afe8e6..5492042acbf 100644
> --- a/nbd/trace-events
> +++ b/nbd/trace-events
> @@ -1,6 +1,7 @@
> # nbd/client.c
> nbd_send_option_request(uint32_t opt, const char *name, uint32_t len) "Sending option request %" PRIu32" (%s), len %" PRIu32
> nbd_receive_option_reply(uint32_t option, const char *optname, uint32_t type, const char *typename, uint32_t length) "Received option reply %" PRIu32" (%s), type %" PRIu32" (%s), len %" PRIu32
> +nbd_server_error_msg(uint32_t err, const char *type, const char *msg) "server reported error 0x%" PRIx32 " (%s) with additional message: %s"
> nbd_reply_err_unsup(uint32_t option, const char *name) "server doesn't understand request %" PRIu32 " (%s), attempting fallback"
> nbd_opt_go_start(const char *name) "Attempting NBD_OPT_GO for export '%s'"
> nbd_opt_go_success(void) "Export is good to go"
>
--
Best regards,
Vladimir
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/3] nbd-client: drop extra error noise
2018-12-18 22:57 [Qemu-devel] [PATCH v2 0/3] nbd-client: drop extra error noise Eric Blake
` (2 preceding siblings ...)
2018-12-18 22:57 ` [Qemu-devel] [PATCH v2 3/3] block/nbd-client: use traces instead of noisy error_report_err Eric Blake
@ 2018-12-19 12:03 ` Vladimir Sementsov-Ogievskiy
2018-12-19 17:22 ` Eric Blake
3 siblings, 1 reply; 7+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2018-12-19 12:03 UTC (permalink / raw)
To: Eric Blake, qemu-devel@nongnu.org
19.12.2018 1:57, Eric Blake wrote:
> This is a counter-proposal to Vladimir's initial post for
> reducing the noise in iotest 083. The difference is that
> I dropped error_get_hint, since I couldn't find any useful
> hint to be traced during transmission phase in the first place,
> and instead added a trace message for the one place where we
> do set hints during handshaking phase.
OK, agree with the idea.
>
> Eric Blake (1):
> nbd/client: Trace all server option error messages
>
> Vladimir Sementsov-Ogievskiy (2):
> nbd: publish _lookup functions
> block/nbd-client: use traces instead of noisy error_report_err
>
> include/block/nbd.h | 5 +++++
> nbd/nbd-internal.h | 5 -----
> block/nbd-client.c | 23 +++++++++++++++++++----
> nbd/client.c | 2 ++
> block/trace-events | 4 ++++
> nbd/trace-events | 1 +
> tests/qemu-iotests/083.out | 28 ----------------------------
> 7 files changed, 31 insertions(+), 37 deletions(-)
>
--
Best regards,
Vladimir
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/3] nbd-client: drop extra error noise
2018-12-19 12:03 ` [Qemu-devel] [PATCH v2 0/3] nbd-client: drop extra error noise Vladimir Sementsov-Ogievskiy
@ 2018-12-19 17:22 ` Eric Blake
0 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2018-12-19 17:22 UTC (permalink / raw)
To: Vladimir Sementsov-Ogievskiy, qemu-devel@nongnu.org
On 12/19/18 6:03 AM, Vladimir Sementsov-Ogievskiy wrote:
> 19.12.2018 1:57, Eric Blake wrote:
>> This is a counter-proposal to Vladimir's initial post for
>> reducing the noise in iotest 083. The difference is that
>> I dropped error_get_hint, since I couldn't find any useful
>> hint to be traced during transmission phase in the first place,
>> and instead added a trace message for the one place where we
>> do set hints during handshaking phase.
>
> OK, agree with the idea.
Thanks. I'll queue this one through my NBD tree and send a pull request
soon (although depending on timing, Peter might not apply it until
January...)
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-12-19 17:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-18 22:57 [Qemu-devel] [PATCH v2 0/3] nbd-client: drop extra error noise Eric Blake
2018-12-18 22:57 ` [Qemu-devel] [PATCH v2 1/3] nbd: publish _lookup functions Eric Blake
2018-12-18 22:57 ` [Qemu-devel] [PATCH v2 2/3] nbd/client: Trace all server option error messages Eric Blake
2018-12-19 11:41 ` Vladimir Sementsov-Ogievskiy
2018-12-18 22:57 ` [Qemu-devel] [PATCH v2 3/3] block/nbd-client: use traces instead of noisy error_report_err Eric Blake
2018-12-19 12:03 ` [Qemu-devel] [PATCH v2 0/3] nbd-client: drop extra error noise Vladimir Sementsov-Ogievskiy
2018-12-19 17:22 ` Eric Blake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).