Gentoo Archives: gentoo-commits

From: Lars Wendler <polynomial-c@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/quota/files/, sys-fs/quota/
Date: Tue, 18 Sep 2018 08:54:17
Message-Id: 1537260841.b97ff58fca5ce104dbc558200389dd6ddda9e64e.polynomial-c@gentoo
1 commit: b97ff58fca5ce104dbc558200389dd6ddda9e64e
2 Author: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
3 AuthorDate: Tue Sep 18 08:54:01 2018 +0000
4 Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
5 CommitDate: Tue Sep 18 08:54:01 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b97ff58f
7
8 sys-fs/quota: Fixed high CPU usage with USE="rpc".
9
10 Closes: https://bugs.gentoo.org/658022
11 Package-Manager: Portage-2.3.49, Repoman-2.3.10
12
13 .../files/quota-4.04-Listen-on-a-TCP-socket.patch | 77 ++++++++++++++++++++
14 sys-fs/quota/quota-4.04-r2.ebuild | 82 ++++++++++++++++++++++
15 2 files changed, 159 insertions(+)
16
17 diff --git a/sys-fs/quota/files/quota-4.04-Listen-on-a-TCP-socket.patch b/sys-fs/quota/files/quota-4.04-Listen-on-a-TCP-socket.patch
18 new file mode 100644
19 index 00000000000..cf1bd4aad32
20 --- /dev/null
21 +++ b/sys-fs/quota/files/quota-4.04-Listen-on-a-TCP-socket.patch
22 @@ -0,0 +1,77 @@
23 +From 31ecd29b3b3f51145fd78f63087c10e9fcadf999 Mon Sep 17 00:00:00 2001
24 +From: Steve Dickson <steved@××××××.com>
25 +Date: Tue, 22 May 2018 12:41:59 +0200
26 +Subject: [PATCH] Listen on a TCP socket
27 +MIME-Version: 1.0
28 +Content-Type: text/plain; charset=UTF-8
29 +Content-Transfer-Encoding: 8bit
30 +
31 +rpc.rquotad spins in libtirpc's rendezvous_request() on accepting TCP
32 +connections because the polled TCP socket is not listening:
33 +
34 +poll([{fd=4, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}, {fd=5,
35 + events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}, {fd=6,
36 + events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}, {fd=7,
37 + events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 4, -1) = 2 ([{fd=5,
38 + revents=POLLHUP}, {fd=7, revents=POLLHUP}])
39 +accept(5, 0x7ffe61698700, [128]) = -1 EINVAL (Invalid argument)
40 +accept(7, 0x7ffe61698700, [128]) = -1 EINVAL (Invalid argument)
41 +
42 +The polled descriptors are:
43 +
44 +rpc.rquot 21981 root 4u IPv4 80449159 0t0 UDP *:rquotad
45 +rpc.rquot 21981 root 5u sock 0,9 0t0 80449162 protocol: TCP
46 +rpc.rquot 21981 root 6u IPv6 80449165 0t0 UDP *:rquotad
47 +rpc.rquot 21981 root 7u sock 0,9 0t0 80449168 protocol: TCPv6
48 +
49 +That results into a high CPU usage just after staring rpc.rquotad
50 +process.
51 +
52 +This patch adds a listen() call to svc_create_sock()
53 +routine which is needed with libtirpc version of svc_tli_create()
54 +as well as a needed IPv6 setsockopt().
55 +
56 +Signed-off-by: Petr Písař <ppisar@××××××.com>
57 +---
58 + svc_socket.c | 18 ++++++++++++++++++
59 + 1 file changed, 18 insertions(+)
60 +
61 +diff --git a/svc_socket.c b/svc_socket.c
62 +index 8a44604..d2e3abf 100644
63 +--- a/svc_socket.c
64 ++++ b/svc_socket.c
65 +@@ -118,6 +118,15 @@ static int svc_create_sock(struct addrinfo *ai)
66 + return -1;
67 + }
68 +
69 ++ if (ai->ai_family == AF_INET6) {
70 ++ if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY,
71 ++ &optval, sizeof(optval)) < 0) {
72 ++ errstr(_("Cannot set IPv6 socket options: %s\n"), strerror(errno));
73 ++ close(fd);
74 ++ return -1;
75 ++ }
76 ++ }
77 ++
78 + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) < 0) {
79 + errstr(_("Cannot set socket options: %s\n"), strerror(errno));
80 + close(fd);
81 +@@ -129,6 +138,15 @@ static int svc_create_sock(struct addrinfo *ai)
82 + close(fd);
83 + return -1;
84 + }
85 ++
86 ++ if (ai->ai_protocol == IPPROTO_TCP) {
87 ++ if (listen(fd, SOMAXCONN) < 0) {
88 ++ errstr(_("Cannot listen to address: %s\n"), strerror(errno));
89 ++ close(fd);
90 ++ return -1;
91 ++ }
92 ++ }
93 ++
94 + return fd;
95 + }
96 +
97 +--
98 +2.14.3
99 +
100
101 diff --git a/sys-fs/quota/quota-4.04-r2.ebuild b/sys-fs/quota/quota-4.04-r2.ebuild
102 new file mode 100644
103 index 00000000000..a6080157d8e
104 --- /dev/null
105 +++ b/sys-fs/quota/quota-4.04-r2.ebuild
106 @@ -0,0 +1,82 @@
107 +# Copyright 1999-2018 Gentoo Foundation
108 +# Distributed under the terms of the GNU General Public License v2
109 +
110 +EAPI=6
111 +
112 +inherit autotools
113 +
114 +DESCRIPTION="Linux quota tools"
115 +HOMEPAGE="https://sourceforge.net/projects/linuxquota/"
116 +SRC_URI="mirror://sourceforge/linuxquota/${P}.tar.gz"
117 +
118 +LICENSE="GPL-2"
119 +SLOT="0"
120 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86"
121 +IUSE="ldap netlink nls rpc tcpd"
122 +
123 +RDEPEND="
124 + ldap? ( >=net-nds/openldap-2.3.35 )
125 + netlink? (
126 + sys-apps/dbus
127 + dev-libs/libnl:3
128 + )
129 + rpc? (
130 + net-nds/rpcbind
131 + elibc_glibc? ( sys-libs/glibc[-rpc(-)] )
132 + net-libs/libtirpc
133 + net-libs/rpcsvc-proto
134 + )
135 + tcpd? ( sys-apps/tcp-wrappers )
136 +"
137 +DEPEND="
138 + ${RDEPEND}
139 + nls? ( sys-devel/gettext )
140 +"
141 +
142 +PATCHES=(
143 + "${FILESDIR}/${P}-glibc226.patch"
144 + "${FILESDIR}/${P}-Listen-on-a-TCP-socket.patch"
145 +)
146 +
147 +src_prepare() {
148 + default
149 + eautoreconf
150 +}
151 +
152 +src_configure() {
153 + local myeconfargs=(
154 + --docdir="${EPREFIX%/}/usr/share/doc/${PF}"
155 + $(use_enable nls)
156 + $(use_enable ldap ldapmail)
157 + $(use_enable netlink)
158 + $(use_enable rpc)
159 + $(use_enable rpc rpcsetquota)
160 + )
161 + econf "${myeconfargs[@]}"
162 +}
163 +
164 +src_install() {
165 + emake DESTDIR="${D}" install
166 + dodoc doc/* README.* Changelog
167 +
168 + insinto /etc
169 + insopts -m0644
170 + doins warnquota.conf quotatab
171 +
172 + newinitd "${FILESDIR}"/quota.rc7 quota
173 + newconfd "${FILESDIR}"/quota.confd quota
174 +
175 + if use rpc ; then
176 + newinitd "${FILESDIR}"/rpc.rquotad.initd rpc.rquotad
177 + fi
178 +
179 + if use ldap ; then
180 + insinto /etc/openldap/schema
181 + insopts -m0644
182 + doins "${FILESDIR}"/ldap-scripts/quota.schema
183 +
184 + exeinto /usr/share/quota/ldap-scripts
185 + doexe "${FILESDIR}"/ldap-scripts/*.pl
186 + doexe "${FILESDIR}"/ldap-scripts/edquota_editor
187 + fi
188 +}