* [PATCH v2] qemu-nbd: Use SOMAXCONN for socket listen() backlog
@ 2021-02-05 18:57 Eric Blake
2021-02-05 19:55 ` Nir Soffer
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Eric Blake @ 2021-02-05 18:57 UTC (permalink / raw)
To: qemu-devel; +Cc: berrange, rjones, qemu-block
Our default of a backlog of 1 connection is rather puny, particularly
for scenarios where we expect multiple listeners to connect (such as
qemu-nbd -e X). This is especially important for Unix sockets, as a
definite benefit to clients: at least on Linux, a client trying to
connect to a Unix socket with a backlog gets an EAGAIN failure with no
way to poll() for when the backlog is no longer present short of
sleeping an arbitrary amount of time before retrying.
See https://bugzilla.redhat.com/1925045 for a demonstration of where
our low backlog prevents libnbd from connecting as many parallel
clients as it wants.
Reported-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
v2: target the correct API used by qemu-nbd, rather than an unrelated
legacy wrapper [Dan]
qemu-nbd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 608c63e82a25..cd20ee73be19 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -965,7 +965,8 @@ int main(int argc, char **argv)
server = qio_net_listener_new();
if (socket_activation == 0) {
saddr = nbd_build_socket_address(sockpath, bindto, port);
- if (qio_net_listener_open_sync(server, saddr, 1, &local_err) < 0) {
+ if (qio_net_listener_open_sync(server, saddr, SOMAXCONN,
+ &local_err) < 0) {
object_unref(OBJECT(server));
error_report_err(local_err);
exit(EXIT_FAILURE);
--
2.30.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] qemu-nbd: Use SOMAXCONN for socket listen() backlog
2021-02-05 18:57 [PATCH v2] qemu-nbd: Use SOMAXCONN for socket listen() backlog Eric Blake
@ 2021-02-05 19:55 ` Nir Soffer
2021-02-08 16:49 ` Eric Blake
2021-02-05 20:19 ` Richard W.M. Jones
2021-02-08 10:00 ` Daniel P. Berrangé
2 siblings, 1 reply; 6+ messages in thread
From: Nir Soffer @ 2021-02-05 19:55 UTC (permalink / raw)
To: Eric Blake; +Cc: Daniel Berrange, QEMU Developers, qemu-block, Richard Jones
On Fri, Feb 5, 2021 at 8:57 PM Eric Blake <eblake@redhat.com> wrote:
>
> Our default of a backlog of 1 connection is rather puny, particularly
> for scenarios where we expect multiple listeners to connect (such as
> qemu-nbd -e X). This is especially important for Unix sockets, as a
> definite benefit to clients: at least on Linux, a client trying to
> connect to a Unix socket with a backlog gets an EAGAIN failure with no
> way to poll() for when the backlog is no longer present short of
> sleeping an arbitrary amount of time before retrying.
>
> See https://bugzilla.redhat.com/1925045 for a demonstration of where
> our low backlog prevents libnbd from connecting as many parallel
> clients as it wants.
>
> Reported-by: Richard W.M. Jones <rjones@redhat.com>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>
> v2: target the correct API used by qemu-nbd, rather than an unrelated
> legacy wrapper [Dan]
>
> qemu-nbd.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index 608c63e82a25..cd20ee73be19 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -965,7 +965,8 @@ int main(int argc, char **argv)
> server = qio_net_listener_new();
> if (socket_activation == 0) {
> saddr = nbd_build_socket_address(sockpath, bindto, port);
> - if (qio_net_listener_open_sync(server, saddr, 1, &local_err) < 0) {
> + if (qio_net_listener_open_sync(server, saddr, SOMAXCONN,
Shouldn't we use value based on --shared=N?
Using maximum value makes sense for generic server expecting to handle many
connections from different clients. qemu-nbd is typically used by one
client, and we
need to make it possible to connect a known number of connections quickly.
> + &local_err) < 0) {
> object_unref(OBJECT(server));
> error_report_err(local_err);
> exit(EXIT_FAILURE);
> --
> 2.30.0
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] qemu-nbd: Use SOMAXCONN for socket listen() backlog
2021-02-05 18:57 [PATCH v2] qemu-nbd: Use SOMAXCONN for socket listen() backlog Eric Blake
2021-02-05 19:55 ` Nir Soffer
@ 2021-02-05 20:19 ` Richard W.M. Jones
2021-02-08 10:00 ` Daniel P. Berrangé
2 siblings, 0 replies; 6+ messages in thread
From: Richard W.M. Jones @ 2021-02-05 20:19 UTC (permalink / raw)
To: Eric Blake; +Cc: berrange, qemu-devel, qemu-block
On Fri, Feb 05, 2021 at 12:57:05PM -0600, Eric Blake wrote:
> Our default of a backlog of 1 connection is rather puny, particularly
> for scenarios where we expect multiple listeners to connect (such as
> qemu-nbd -e X). This is especially important for Unix sockets, as a
> definite benefit to clients: at least on Linux, a client trying to
> connect to a Unix socket with a backlog gets an EAGAIN failure with no
> way to poll() for when the backlog is no longer present short of
> sleeping an arbitrary amount of time before retrying.
>
> See https://bugzilla.redhat.com/1925045 for a demonstration of where
> our low backlog prevents libnbd from connecting as many parallel
> clients as it wants.
>
> Reported-by: Richard W.M. Jones <rjones@redhat.com>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>
> v2: target the correct API used by qemu-nbd, rather than an unrelated
> legacy wrapper [Dan]
>
> qemu-nbd.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index 608c63e82a25..cd20ee73be19 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -965,7 +965,8 @@ int main(int argc, char **argv)
> server = qio_net_listener_new();
> if (socket_activation == 0) {
> saddr = nbd_build_socket_address(sockpath, bindto, port);
> - if (qio_net_listener_open_sync(server, saddr, 1, &local_err) < 0) {
> + if (qio_net_listener_open_sync(server, saddr, SOMAXCONN,
> + &local_err) < 0) {
> object_unref(OBJECT(server));
> error_report_err(local_err);
> exit(EXIT_FAILURE);
This one works:
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] qemu-nbd: Use SOMAXCONN for socket listen() backlog
2021-02-05 18:57 [PATCH v2] qemu-nbd: Use SOMAXCONN for socket listen() backlog Eric Blake
2021-02-05 19:55 ` Nir Soffer
2021-02-05 20:19 ` Richard W.M. Jones
@ 2021-02-08 10:00 ` Daniel P. Berrangé
2021-02-08 16:45 ` Eric Blake
2 siblings, 1 reply; 6+ messages in thread
From: Daniel P. Berrangé @ 2021-02-08 10:00 UTC (permalink / raw)
To: Eric Blake; +Cc: qemu-devel, qemu-block, rjones
On Fri, Feb 05, 2021 at 12:57:05PM -0600, Eric Blake wrote:
> Our default of a backlog of 1 connection is rather puny, particularly
> for scenarios where we expect multiple listeners to connect (such as
> qemu-nbd -e X). This is especially important for Unix sockets, as a
> definite benefit to clients: at least on Linux, a client trying to
> connect to a Unix socket with a backlog gets an EAGAIN failure with no
> way to poll() for when the backlog is no longer present short of
> sleeping an arbitrary amount of time before retrying.
>
> See https://bugzilla.redhat.com/1925045 for a demonstration of where
> our low backlog prevents libnbd from connecting as many parallel
> clients as it wants.
>
> Reported-by: Richard W.M. Jones <rjones@redhat.com>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>
> v2: target the correct API used by qemu-nbd, rather than an unrelated
> legacy wrapper [Dan]
>
> qemu-nbd.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index 608c63e82a25..cd20ee73be19 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -965,7 +965,8 @@ int main(int argc, char **argv)
> server = qio_net_listener_new();
> if (socket_activation == 0) {
> saddr = nbd_build_socket_address(sockpath, bindto, port);
> - if (qio_net_listener_open_sync(server, saddr, 1, &local_err) < 0) {
> + if (qio_net_listener_open_sync(server, saddr, SOMAXCONN,
> + &local_err) < 0) {
This addresses qemu-nbd, but surely we want to be consistent with the
QMP nbd-server-start impl too, in blockdev-nbd.c
> object_unref(OBJECT(server));
> error_report_err(local_err);
> exit(EXIT_FAILURE);
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] qemu-nbd: Use SOMAXCONN for socket listen() backlog
2021-02-08 10:00 ` Daniel P. Berrangé
@ 2021-02-08 16:45 ` Eric Blake
0 siblings, 0 replies; 6+ messages in thread
From: Eric Blake @ 2021-02-08 16:45 UTC (permalink / raw)
To: Daniel P. Berrangé; +Cc: qemu-devel, qemu-block, rjones
On 2/8/21 4:00 AM, Daniel P. Berrangé wrote:
> On Fri, Feb 05, 2021 at 12:57:05PM -0600, Eric Blake wrote:
>> Our default of a backlog of 1 connection is rather puny, particularly
>> for scenarios where we expect multiple listeners to connect (such as
>> qemu-nbd -e X). This is especially important for Unix sockets, as a
>> definite benefit to clients: at least on Linux, a client trying to
>> connect to a Unix socket with a backlog gets an EAGAIN failure with no
>> way to poll() for when the backlog is no longer present short of
>> sleeping an arbitrary amount of time before retrying.
>>
>> See https://bugzilla.redhat.com/1925045 for a demonstration of where
>> our low backlog prevents libnbd from connecting as many parallel
>> clients as it wants.
>>
>> Reported-by: Richard W.M. Jones <rjones@redhat.com>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>>
>> v2: target the correct API used by qemu-nbd, rather than an unrelated
>> legacy wrapper [Dan]
>>
>> qemu-nbd.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/qemu-nbd.c b/qemu-nbd.c
>> index 608c63e82a25..cd20ee73be19 100644
>> --- a/qemu-nbd.c
>> +++ b/qemu-nbd.c
>> @@ -965,7 +965,8 @@ int main(int argc, char **argv)
>> server = qio_net_listener_new();
>> if (socket_activation == 0) {
>> saddr = nbd_build_socket_address(sockpath, bindto, port);
>> - if (qio_net_listener_open_sync(server, saddr, 1, &local_err) < 0) {
>> + if (qio_net_listener_open_sync(server, saddr, SOMAXCONN,
>> + &local_err) < 0) {
>
> This addresses qemu-nbd, but surely we want to be consistent with the
> QMP nbd-server-start impl too, in blockdev-nbd.c
>
Good point, I'll send v3.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] qemu-nbd: Use SOMAXCONN for socket listen() backlog
2021-02-05 19:55 ` Nir Soffer
@ 2021-02-08 16:49 ` Eric Blake
0 siblings, 0 replies; 6+ messages in thread
From: Eric Blake @ 2021-02-08 16:49 UTC (permalink / raw)
To: Nir Soffer; +Cc: Daniel Berrange, QEMU Developers, qemu-block, Richard Jones
On 2/5/21 1:55 PM, Nir Soffer wrote:
> On Fri, Feb 5, 2021 at 8:57 PM Eric Blake <eblake@redhat.com> wrote:
>>
>> Our default of a backlog of 1 connection is rather puny, particularly
>> for scenarios where we expect multiple listeners to connect (such as
>> qemu-nbd -e X). This is especially important for Unix sockets, as a
>> definite benefit to clients: at least on Linux, a client trying to
>> connect to a Unix socket with a backlog gets an EAGAIN failure with no
>> way to poll() for when the backlog is no longer present short of
>> sleeping an arbitrary amount of time before retrying.
>>
>> See https://bugzilla.redhat.com/1925045 for a demonstration of where
>> our low backlog prevents libnbd from connecting as many parallel
>> clients as it wants.
>>
>> Reported-by: Richard W.M. Jones <rjones@redhat.com>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>>
>> v2: target the correct API used by qemu-nbd, rather than an unrelated
>> legacy wrapper [Dan]
>>
>> qemu-nbd.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/qemu-nbd.c b/qemu-nbd.c
>> index 608c63e82a25..cd20ee73be19 100644
>> --- a/qemu-nbd.c
>> +++ b/qemu-nbd.c
>> @@ -965,7 +965,8 @@ int main(int argc, char **argv)
>> server = qio_net_listener_new();
>> if (socket_activation == 0) {
>> saddr = nbd_build_socket_address(sockpath, bindto, port);
>> - if (qio_net_listener_open_sync(server, saddr, 1, &local_err) < 0) {
>> + if (qio_net_listener_open_sync(server, saddr, SOMAXCONN,
>
> Shouldn't we use value based on --shared=N?
That's a possibility. I don't know how many resources we tie up if we
allow more clients to try to connect() than what we will ultimately
accept when --shared is small.
But there's also the issue that for qemu-nbd, we default to 1 client
unless you pass -e/--shared on the command line, whereas starting an NBD
server in qemu via QMP (including via qemu-storage-daemon) defaults
max-connections to 0 meaning unlimited.
>
> Using maximum value makes sense for generic server expecting to handle many
> connections from different clients. qemu-nbd is typically used by one
> client, and we
> need to make it possible to connect a known number of connections quickly.
At any rate, when max-connections is specified to something smaller than
SOMAXCONN, listen()ing to a smaller number of connections seems
reasonable, so I'll play with that for v3.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-02-08 21:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-05 18:57 [PATCH v2] qemu-nbd: Use SOMAXCONN for socket listen() backlog Eric Blake
2021-02-05 19:55 ` Nir Soffer
2021-02-08 16:49 ` Eric Blake
2021-02-05 20:19 ` Richard W.M. Jones
2021-02-08 10:00 ` Daniel P. Berrangé
2021-02-08 16:45 ` 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).