From owner-dev-commits-src-branches@freebsd.org Sun Jun 13 01:45:00 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 78DAF6541D2; Sun, 13 Jun 2021 01:45:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G2cpN2rF8z4jbQ; Sun, 13 Jun 2021 01:45:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 495C118CAA; Sun, 13 Jun 2021 01:45:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15D1j0gH051802; Sun, 13 Jun 2021 01:45:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15D1j0lc051801; Sun, 13 Jun 2021 01:45:00 GMT (envelope-from git) Date: Sun, 13 Jun 2021 01:45:00 GMT Message-Id: <202106130145.15D1j0lc051801@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 11cfede1e62a - stable/13 - accounting: explicitly mark the exiting thread as doing accounting MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 11cfede1e62afa1ff00cf97107bc48ebe1561ecb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jun 2021 01:45:00 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=11cfede1e62afa1ff00cf97107bc48ebe1561ecb commit 11cfede1e62afa1ff00cf97107bc48ebe1561ecb Author: Konstantin Belousov AuthorDate: 2021-05-13 23:48:58 +0000 Commit: Konstantin Belousov CommitDate: 2021-06-13 01:22:33 +0000 accounting: explicitly mark the exiting thread as doing accounting (cherry picked from commit 9bb84c23e762e7d1b6154ef4afdcc80662692e76) --- sys/kern/kern_acct.c | 26 +++++--------------------- sys/kern/vfs_vnops.c | 3 ++- sys/sys/proc.h | 1 + 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index 675113c6b2ba..4c1efada10da 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -141,7 +141,6 @@ static int acct_configured; static int acct_suspended; static struct vnode *acct_vp; static struct ucred *acct_cred; -static struct plimit *acct_limit; static int acct_flags; static struct sx acct_sx; @@ -206,7 +205,7 @@ int sys_acct(struct thread *td, struct acct_args *uap) { struct nameidata nd; - int error, flags, i, replacing; + int error, flags, replacing; error = priv_check(td, PRIV_ACCT); if (error) @@ -276,15 +275,6 @@ sys_acct(struct thread *td, struct acct_args *uap) return (error); } - /* - * Create our own plimit object without limits. It will be assigned - * to exiting processes. - */ - acct_limit = lim_alloc(); - for (i = 0; i < RLIM_NLIMITS; i++) - acct_limit->pl_rlimit[i].rlim_cur = - acct_limit->pl_rlimit[i].rlim_max = RLIM_INFINITY; - /* * Save the new accounting file vnode, and schedule the new * free space watcher. @@ -328,7 +318,6 @@ acct_disable(struct thread *td, int logging) sx_assert(&acct_sx, SX_XLOCKED); error = vn_close(acct_vp, acct_flags, acct_cred, td); crfree(acct_cred); - lim_free(acct_limit); acct_configured = 0; acct_vp = NULL; acct_cred = NULL; @@ -349,7 +338,6 @@ acct_process(struct thread *td) { struct acctv3 acct; struct timeval ut, st, tmp; - struct plimit *oldlim; struct proc *p; struct rusage ru; int t, ret; @@ -374,6 +362,7 @@ acct_process(struct thread *td) } p = td->td_proc; + td->td_pflags2 |= TDP2_ACCT; /* * Get process accounting information. @@ -426,20 +415,14 @@ acct_process(struct thread *td) /* (8) The boolean flags that tell how the process terminated, etc. */ acct.ac_flagx = p->p_acflag; + PROC_UNLOCK(p); + /* Setup ancillary structure fields. */ acct.ac_flagx |= ANVER; acct.ac_zero = 0; acct.ac_version = 3; acct.ac_len = acct.ac_len2 = sizeof(acct); - /* - * Eliminate rlimits (file size limit in particular). - */ - oldlim = p->p_limit; - p->p_limit = lim_hold(acct_limit); - PROC_UNLOCK(p); - lim_free(oldlim); - /* * Write the accounting information to the file. */ @@ -447,6 +430,7 @@ acct_process(struct thread *td) (off_t)0, UIO_SYSSPACE, IO_APPEND|IO_UNIT, acct_cred, NOCRED, NULL, td); sx_sunlock(&acct_sx); + td->td_pflags2 &= ~TDP2_ACCT; return (ret); } diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 4ce4678f292f..8be30df40dc5 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2361,7 +2361,8 @@ vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, struct thread *td) { - if (vp->v_type != VREG || td == NULL) + if (vp->v_type != VREG || td == NULL || + (td->td_pflags2 & TDP2_ACCT) != 0) return (0); if ((uoff_t)uio->uio_offset + uio->uio_resid > lim_cur(td, RLIMIT_FSIZE)) { diff --git a/sys/sys/proc.h b/sys/sys/proc.h index b0fc13a449cb..b47af58c34be 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -527,6 +527,7 @@ do { \ #define TDP2_SBPAGES 0x00000001 /* Owns sbusy on some pages */ #define TDP2_COMPAT32RB 0x00000002 /* compat32 ABI for robust lists */ +#define TDP2_ACCT 0x00000004 /* Doing accounting */ /* * Reasons that the current thread can not be run yet.