From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id E3C98138334 for ; Tue, 18 Sep 2018 08:54:17 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 82E19E0DF2; Tue, 18 Sep 2018 08:54:16 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 46F1BE0DF2 for ; Tue, 18 Sep 2018 08:54:16 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 48F90335CD6 for ; Tue, 18 Sep 2018 08:54:14 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3C5313D3 for ; Tue, 18 Sep 2018 08:54:12 +0000 (UTC) From: "Lars Wendler" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Lars Wendler" Message-ID: <1537260841.b97ff58fca5ce104dbc558200389dd6ddda9e64e.polynomial-c@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/quota/files/, sys-fs/quota/ X-VCS-Repository: repo/gentoo X-VCS-Files: sys-fs/quota/files/quota-4.04-Listen-on-a-TCP-socket.patch sys-fs/quota/quota-4.04-r2.ebuild X-VCS-Directories: sys-fs/quota/ sys-fs/quota/files/ X-VCS-Committer: polynomial-c X-VCS-Committer-Name: Lars Wendler X-VCS-Revision: b97ff58fca5ce104dbc558200389dd6ddda9e64e X-VCS-Branch: master Date: Tue, 18 Sep 2018 08:54:12 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: f270f9a6-22d3-4ef2-9cbc-a4a3c720460e X-Archives-Hash: 2562115afd54b9111119f1cc94c6852b commit: b97ff58fca5ce104dbc558200389dd6ddda9e64e Author: Lars Wendler gentoo org> AuthorDate: Tue Sep 18 08:54:01 2018 +0000 Commit: Lars Wendler gentoo org> CommitDate: Tue Sep 18 08:54:01 2018 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b97ff58f sys-fs/quota: Fixed high CPU usage with USE="rpc". Closes: https://bugs.gentoo.org/658022 Package-Manager: Portage-2.3.49, Repoman-2.3.10 .../files/quota-4.04-Listen-on-a-TCP-socket.patch | 77 ++++++++++++++++++++ sys-fs/quota/quota-4.04-r2.ebuild | 82 ++++++++++++++++++++++ 2 files changed, 159 insertions(+) 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 new file mode 100644 index 00000000000..cf1bd4aad32 --- /dev/null +++ b/sys-fs/quota/files/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/sys-fs/quota/quota-4.04-r2.ebuild b/sys-fs/quota/quota-4.04-r2.ebuild new file mode 100644 index 00000000000..a6080157d8e --- /dev/null +++ b/sys-fs/quota/quota-4.04-r2.ebuild @@ -0,0 +1,82 @@ +# Copyright 1999-2018 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +inherit autotools + +DESCRIPTION="Linux quota tools" +HOMEPAGE="https://sourceforge.net/projects/linuxquota/" +SRC_URI="mirror://sourceforge/linuxquota/${P}.tar.gz" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86" +IUSE="ldap netlink nls rpc tcpd" + +RDEPEND=" + ldap? ( >=net-nds/openldap-2.3.35 ) + netlink? ( + sys-apps/dbus + dev-libs/libnl:3 + ) + rpc? ( + net-nds/rpcbind + elibc_glibc? ( sys-libs/glibc[-rpc(-)] ) + net-libs/libtirpc + net-libs/rpcsvc-proto + ) + tcpd? ( sys-apps/tcp-wrappers ) +" +DEPEND=" + ${RDEPEND} + nls? ( sys-devel/gettext ) +" + +PATCHES=( + "${FILESDIR}/${P}-glibc226.patch" + "${FILESDIR}/${P}-Listen-on-a-TCP-socket.patch" +) + +src_prepare() { + default + eautoreconf +} + +src_configure() { + local myeconfargs=( + --docdir="${EPREFIX%/}/usr/share/doc/${PF}" + $(use_enable nls) + $(use_enable ldap ldapmail) + $(use_enable netlink) + $(use_enable rpc) + $(use_enable rpc rpcsetquota) + ) + econf "${myeconfargs[@]}" +} + +src_install() { + emake DESTDIR="${D}" install + dodoc doc/* README.* Changelog + + insinto /etc + insopts -m0644 + doins warnquota.conf quotatab + + newinitd "${FILESDIR}"/quota.rc7 quota + newconfd "${FILESDIR}"/quota.confd quota + + if use rpc ; then + newinitd "${FILESDIR}"/rpc.rquotad.initd rpc.rquotad + fi + + if use ldap ; then + insinto /etc/openldap/schema + insopts -m0644 + doins "${FILESDIR}"/ldap-scripts/quota.schema + + exeinto /usr/share/quota/ldap-scripts + doexe "${FILESDIR}"/ldap-scripts/*.pl + doexe "${FILESDIR}"/ldap-scripts/edquota_editor + fi +}