From owner-freebsd-bugs@FreeBSD.ORG Wed May 2 14:30:16 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7F9F11065674 for ; Wed, 2 May 2012 14:30:16 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 6A0318FC12 for ; Wed, 2 May 2012 14:30:16 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q42EUG92004136 for ; Wed, 2 May 2012 14:30:16 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q42EUGe8004133; Wed, 2 May 2012 14:30:16 GMT (envelope-from gnats) Date: Wed, 2 May 2012 14:30:16 GMT Message-Id: <201205021430.q42EUGe8004133@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: dfilter@FreeBSD.ORG (dfilter service) Cc: Subject: Re: kern/167321: commit references a PR X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: dfilter service List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 14:30:16 -0000 The following reply was made to PR kern/167321; it has been noted by GNATS. From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: kern/167321: commit references a PR Date: Wed, 2 May 2012 14:25:53 +0000 (UTC) Author: jhb Date: Wed May 2 14:25:39 2012 New Revision: 234927 URL: http://svn.freebsd.org/changeset/base/234927 Log: - Don't log messages saying that accounting is being disabled and enabled if the accounting log file is atomically replaced with a new file (such as during log rotation). - Simplify accounting log rotation a bit. There is no need to re-run accton(8) after renaming the new log file to it's real name. PR: kern/167321 Tested by: Jeremy Chadwick Modified: head/etc/rc.d/accounting head/sys/kern/kern_acct.c Modified: head/etc/rc.d/accounting ============================================================================== --- head/etc/rc.d/accounting Wed May 2 12:15:34 2012 (r234926) +++ head/etc/rc.d/accounting Wed May 2 14:25:39 2012 (r234927) @@ -65,9 +65,7 @@ accounting_rotate_log() mv ${accounting_file} ${accounting_file}.0 if checkyesno accounting_enable; then - ln $_file ${accounting_file##*/} - ${accounting_command} ${accounting_file} - unlink $_file + mv $_file ${accounting_file} fi } Modified: head/sys/kern/kern_acct.c ============================================================================== --- head/sys/kern/kern_acct.c Wed May 2 12:15:34 2012 (r234926) +++ head/sys/kern/kern_acct.c Wed May 2 14:25:39 2012 (r234927) @@ -122,7 +122,7 @@ static uint32_t encode_timeval(struct ti static uint32_t encode_long(long); static void acctwatch(void); static void acct_thread(void *); -static int acct_disable(struct thread *); +static int acct_disable(struct thread *, int); /* * Accounting vnode pointer, saved vnode pointer, and flags for each. @@ -196,7 +196,7 @@ int sys_acct(struct thread *td, struct acct_args *uap) { struct nameidata nd; - int error, flags, vfslocked; + int error, flags, vfslocked, replacing; error = priv_check(td, PRIV_ACCT); if (error) @@ -246,6 +246,13 @@ sys_acct(struct thread *td, struct acct_ sx_xlock(&acct_sx); /* + * Don't log spurious disable/enable messages if we are + * switching from one accounting file to another due to log + * rotation. + */ + replacing = (acct_vp != NULL && uap->path != NULL); + + /* * If accounting was previously enabled, kill the old space-watcher, * close the file, and (if no new file was specified, leave). Reset * the suspended state regardless of whether accounting remains @@ -254,7 +261,7 @@ sys_acct(struct thread *td, struct acct_ acct_suspended = 0; if (acct_vp != NULL) { vfslocked = VFS_LOCK_GIANT(acct_vp->v_mount); - error = acct_disable(td); + error = acct_disable(td, !replacing); VFS_UNLOCK_GIANT(vfslocked); } if (uap->path == NULL) { @@ -299,7 +306,8 @@ sys_acct(struct thread *td, struct acct_ } acct_configured = 1; sx_xunlock(&acct_sx); - log(LOG_NOTICE, "Accounting enabled\n"); + if (!replacing) + log(LOG_NOTICE, "Accounting enabled\n"); return (error); } @@ -308,7 +316,7 @@ sys_acct(struct thread *td, struct acct_ * our reference to the credential, and clearing the vnode's flags. */ static int -acct_disable(struct thread *td) +acct_disable(struct thread *td, int logging) { int error; @@ -319,7 +327,8 @@ acct_disable(struct thread *td) acct_vp = NULL; acct_cred = NULL; acct_flags = 0; - log(LOG_NOTICE, "Accounting disabled\n"); + if (logging) + log(LOG_NOTICE, "Accounting disabled\n"); return (error); } @@ -574,7 +583,7 @@ acctwatch(void) */ vfslocked = VFS_LOCK_GIANT(acct_vp->v_mount); if (acct_vp->v_type == VBAD) { - (void) acct_disable(NULL); + (void) acct_disable(NULL, 1); VFS_UNLOCK_GIANT(vfslocked); acct_state |= ACCT_EXITREQ; return; _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"