Subject: accounting daemon bug fixed + sysctl accounting threshold (#415) Index: sys/subr_log.c,kern_sysctl.c,kern_acct.c 2.11BSD Description: 1. A bug in the circular buffer logic would cause the accounting daemon to repeatedly read the same data creating very large accounting files. 2. The threshold of accouting events after which a wakeup() would be done on the accounting daemon was hard coded at 10. Repeat-By: 1. After applying updates 412 and 413 run the system for a little while and notice that /usr/adm/acct was many megabytes in size. 2. Observation. Fix: 1. Two lines of code which had been deleted the last time this bug was fixed somehow reappeared. They have been deleted again. This time forever ;) 2. A sysctl(8) interface to examine and change the number of accounting events that must occur before a wakeup() of acctd(8) was added. The default is 10 (10 records are buffered by the kernel before waking up the daemon). To change this to a value between 0 and 128 (inclusive) use: sysctl -w kern.acctthresh=6 If a value of 0 or 1 is specified then acctd(8) is notified after each accounting record is placed in the buffer. This is a fair amount of extra overhead and is probably only desireable when testing. To simply examine the current setting: sysctl kern.acctthresh To install this patch cut where indicated and save to a file (/tmp/415). Then: patch -p0 < /tmp/415 cd /sys/YOURKERNEL make mv /unix /ounix mv /netnix /onetnix mv unix netnix / chmod 744 /unix /netnix cd /usr/src/bin/sysctl make make install reboot As always this and previous updates to 2.11BSD are available via anonymous FTP to either FTP.IIPO.GTEGSC.COM or MOE.2BSD.COM in the directory /pub/2.11BSD. -------------------------cut here---------------------- *** /usr/src/sys/sys/subr_log.c.old Tue Mar 9 19:44:56 1999 --- /usr/src/sys/sys/subr_log.c Thu Apr 29 19:46:29 1999 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)subr_log.c 2.0 (2.11BSD) 1998/12/5 */ /* --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)subr_log.c 2.1 (2.11BSD) 1999/4/29 */ /* *************** *** 170,177 **** if (error) break; mp->msg_bufr += l; - if (mp->msg_bufr < 0 || mp->msg_bufr >= MSG_BSIZE) - mp->msg_bufr = 0; } splx(s); return(error); --- 170,175 ---- *** /usr/src/sys/sys/kern_acct.c.old Sat Mar 20 20:43:51 1999 --- /usr/src/sys/sys/kern_acct.c Thu Apr 29 19:59:36 1999 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_acct.c 3.0 (2.11BSD) 1999/2/19 * * This module is a shadow of its former self. This comment: * --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_acct.c 3.1 (2.11BSD) 1999/4/29 * * This module is a shadow of its former self. This comment: * *************** *** 20,25 **** --- 20,26 ---- #include "acct.h" comp_t compress(); + int Acctthresh = 10; /* * On exit, write a record on the accounting file. *************** *** 54,65 **** ap->ac_flag = u.u_acflag; /* * Not a lot that can be done if logwrt fails so ignore any errors. Every ! * 10 commands call the wakeup routine. This isn't perfect but does cut ! * down the overhead of issuing a wakeup to the accounting daemon every ! * single accounting record. */ logwrt(ap, sizeof (*ap), logACCT); ! if (acctcnt++ > 10) { logwakeup(logACCT); acctcnt = 0; --- 55,66 ---- ap->ac_flag = u.u_acflag; /* * Not a lot that can be done if logwrt fails so ignore any errors. Every ! * few (10 by default) commands call the wakeup routine. This isn't perfect ! * but does cut down the overhead of issuing a wakeup to the accounting daemon ! * every single accounting record. The threshold is settable via sysctl(8) */ logwrt(ap, sizeof (*ap), logACCT); ! if (++acctcnt >= Acctthresh) { logwakeup(logACCT); acctcnt = 0; *** /usr/src/sys/sys/kern_sysctl.c.old Tue Sep 15 19:57:05 1998 --- /usr/src/sys/sys/kern_sysctl.c Thu Apr 29 20:18:27 1999 *************** *** 33,39 **** * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)kern_sysctl.c 8.4.9 (2.11BSD GTE) 1998/9/15 */ /* --- 33,39 ---- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)kern_sysctl.c 8.4.10 (2.11BSD) 1999/4/29 */ /* *************** *** 186,191 **** --- 186,192 ---- int error, level; u_long longhostid; char bsd[10]; + extern int Acctthresh; /* kern_acct.c */ extern char version[]; /* all sysctl names at this level are terminal */ *************** *** 199,204 **** --- 200,216 ---- bsd[0]='2';bsd[1]='.';bsd[2]='1';bsd[3]='1';bsd[4]='B'; bsd[5]='S';bsd[6]='D';bsd[7]='\0'; return (sysctl_rdstring(oldp, oldlenp, newp, bsd)); + case KERN_ACCTTHRESH: + level = Acctthresh; + error = sysctl_int(oldp, oldlenp, newp, newlen, &level); + if (newp && !error) + { + if (level < 0 || level > 128) + error = EINVAL; + else + Acctthresh = level; + } + return(error); case KERN_OSREV: return (sysctl_rdlong(oldp, oldlenp, newp, (long)BSD)); case KERN_VERSION: *** /usr/src/sys/h/sysctl.h.old Thu Jan 19 21:20:50 1995 --- /usr/src/sys/h/sysctl.h Thu Apr 29 20:02:11 1999 *************** *** 33,39 **** * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)sysctl.h 8.1.2 (2.11BSD GTE) 1/19/95 */ #ifndef _SYS_SYSCTL_H_ --- 33,39 ---- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)sysctl.h 8.1.3 (2.11BSD) 1999/4/29 */ #ifndef _SYS_SYSCTL_H_ *************** *** 135,141 **** #define KERN_BOOTTIME 21 /* struct: time kernel was booted */ #define KERN_MAXTEXTS 22 /* int: # of text entries */ #define KERN_TEXT 23 /* struct: text entries */ ! #define KERN_MAXID 24 /* number of valid kern ids */ #ifndef KERNEL #define CTL_KERN_NAMES { \ --- 135,142 ---- #define KERN_BOOTTIME 21 /* struct: time kernel was booted */ #define KERN_MAXTEXTS 22 /* int: # of text entries */ #define KERN_TEXT 23 /* struct: text entries */ ! #define KERN_ACCTTHRESH 24 /* int: accounting daemon threshold */ ! #define KERN_MAXID 25 /* number of valid kern ids */ #ifndef KERNEL #define CTL_KERN_NAMES { \ *************** *** 163,168 **** --- 164,170 ---- { "boottime", CTLTYPE_STRUCT }, \ { "maxtexts", CTLTYPE_INT }, \ { "text", CTLTYPE_STRUCT }, \ + { "acctthresh", CTLTYPE_INT }, \ } #endif *** /usr/src/bin/sysctl/sysctl.8.old Fri Apr 3 20:33:02 1998 --- /usr/src/bin/sysctl/sysctl.8 Thu Apr 29 20:41:21 1999 *************** *** 29,37 **** .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" ! .\" @(#)sysctl.8 8.1.4 (2.11BSD GTE) 1998/4/3 .\" ! .TH SYSCTL 8 "June 6, 1993" .UC 4 .SH NAME sysctl \- get or set kernel state --- 29,37 ---- .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" ! .\" @(#)sysctl.8 8.1.5 (2.11BSD) 1999/4/29 .\" ! .TH SYSCTL 8 "April 24, 1999" .UC 4 .SH NAME sysctl \- get or set kernel state *************** *** 109,114 **** --- 109,115 ---- .ta 0.5i 3.0i 4.0i .nf Name Type Changeable + kern.acctthresh int yes kern.ostype string no kern.osrelease string no kern.osrevision long no *** /VERSION.old Wed Apr 28 21:51:19 1999 --- /VERSION Thu Apr 29 19:45:43 1999 *************** *** 1,5 **** ! Current Patch Level: 414 ! Date: April 28, 1999 2.11 BSD ============ --- 1,5 ---- ! Current Patch Level: 415 ! Date: April 29, 1999 2.11 BSD ============