From 706ef8f2c4f61694f68ebf0757d587a59f87268b Mon Sep 17 00:00:00 2001 From: Petr Písař Date: May 22 2018 12:10:20 +0000 Subject: Fix busy loop in rpc.rquotad --- diff --git a/quota-4.04-Listen-on-a-TCP-socket.patch b/quota-4.04-Listen-on-a-TCP-socket.patch new file mode 100644 index 0000000..cf1bd4a --- /dev/null +++ b/quota-4.04-Listen-on-a-TCP-socket.patch @@ -0,0 +1,77 @@ +From 31ecd29b3b3f51145fd78f63087c10e9fcadf999 Mon Sep 17 00:00:00 2001 +From: Steve Dickson +Date: Tue, 22 May 2018 12:41:59 +0200 +Subject: [PATCH] Listen on a TCP socket +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +rpc.rquotad spins in libtirpc's rendezvous_request() on accepting TCP +connections because the polled TCP socket is not listening: + +poll([{fd=4, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}, {fd=5, + events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}, {fd=6, + events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}, {fd=7, + events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 4, -1) = 2 ([{fd=5, + revents=POLLHUP}, {fd=7, revents=POLLHUP}]) +accept(5, 0x7ffe61698700, [128]) = -1 EINVAL (Invalid argument) +accept(7, 0x7ffe61698700, [128]) = -1 EINVAL (Invalid argument) + +The polled descriptors are: + +rpc.rquot 21981 root 4u IPv4 80449159 0t0 UDP *:rquotad +rpc.rquot 21981 root 5u sock 0,9 0t0 80449162 protocol: TCP +rpc.rquot 21981 root 6u IPv6 80449165 0t0 UDP *:rquotad +rpc.rquot 21981 root 7u sock 0,9 0t0 80449168 protocol: TCPv6 + +That results into a high CPU usage just after staring rpc.rquotad +process. + +This patch adds a listen() call to svc_create_sock() +routine which is needed with libtirpc version of svc_tli_create() +as well as a needed IPv6 setsockopt(). + +Signed-off-by: Petr Písař +--- + svc_socket.c | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/svc_socket.c b/svc_socket.c +index 8a44604..d2e3abf 100644 +--- a/svc_socket.c ++++ b/svc_socket.c +@@ -118,6 +118,15 @@ static int svc_create_sock(struct addrinfo *ai) + return -1; + } + ++ if (ai->ai_family == AF_INET6) { ++ if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, ++ &optval, sizeof(optval)) < 0) { ++ errstr(_("Cannot set IPv6 socket options: %s\n"), strerror(errno)); ++ close(fd); ++ return -1; ++ } ++ } ++ + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) < 0) { + errstr(_("Cannot set socket options: %s\n"), strerror(errno)); + close(fd); +@@ -129,6 +138,15 @@ static int svc_create_sock(struct addrinfo *ai) + close(fd); + return -1; + } ++ ++ if (ai->ai_protocol == IPPROTO_TCP) { ++ if (listen(fd, SOMAXCONN) < 0) { ++ errstr(_("Cannot listen to address: %s\n"), strerror(errno)); ++ close(fd); ++ return -1; ++ } ++ } ++ + return fd; + } + +-- +2.14.3 + diff --git a/quota.spec b/quota.spec index 7b86e7b..9a1b193 100644 --- a/quota.spec +++ b/quota.spec @@ -10,7 +10,7 @@ Name: quota Epoch: 1 Version: 4.04 -Release: 5%{?dist} +Release: 6%{?dist} Summary: System administration tools for monitoring users' disk usage # quota_nld.c, quotaio_xfs.h: GPLv2 # bylabel.c copied from util-linux: GPLv2+ @@ -73,6 +73,9 @@ Patch7: quota-4.04-quotacheck-Avoid-question-in-non-interactive-mode.patch Patch8: quota-4.04-quotacheck-Report-error-when-caching-of-quota-file-f.patch # Report an error if quota file magic is invalid, in upstream after 4.04 Patch9: quota-4.04-quotacheck-Fail-check-if-quota-file-magic-is-invalid.patch +# Fix busy loop in rpc.rquotad, bug #1575956, +# +Patch10: quota-4.04-Listen-on-a-TCP-socket.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: bash @@ -196,6 +199,7 @@ Linux/UNIX environment. %patch7 -p1 %patch8 -p1 %patch9 -p1 +%patch10 -p1 # Regenerate build scripts autoreconf -f -i @@ -340,6 +344,9 @@ make check %changelog +* Tue May 22 2018 Petr Pisar - 1:4.04-6 +- Fix busy loop in rpc.rquotad (bug #1575956) + * Fri Feb 09 2018 Fedora Release Engineering - 1:4.04-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild