summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_acct.c
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2004-03-04 09:47:09 +0000
committerbde <bde@FreeBSD.org>2004-03-04 09:47:09 +0000
commita3f844af362e90971912cb13a2077c7fe52cff00 (patch)
tree9714df5cfd15bc551b75d9b401211a0cf2f4d14a /sys/kern/kern_acct.c
parentf60d27291ecac01d35e6712e294dc3c3a2a31d08 (diff)
downloadFreeBSD-src-a3f844af362e90971912cb13a2077c7fe52cff00.zip
FreeBSD-src-a3f844af362e90971912cb13a2077c7fe52cff00.tar.gz
Fixed some style bugs (mainly misplaced comments, and totally disordered
declarations in acct_process()).
Diffstat (limited to 'sys/kern/kern_acct.c')
-rw-r--r--sys/kern/kern_acct.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c
index 613a198..63d7891 100644
--- a/sys/kern/kern_acct.c
+++ b/sys/kern/kern_acct.c
@@ -137,6 +137,7 @@ acct(td, uap)
return (error);
mtx_lock(&Giant);
+
/*
* If accounting is to be started to a file, open that file for
* appending and make sure it's a 'normal'.
@@ -169,16 +170,14 @@ acct(td, uap)
#endif
}
+ mtx_lock(&acct_mtx);
+
/*
* If accounting was previously enabled, kill the old space-watcher,
* close the file, and (if no new file was specified, leave).
+ *
+ * XXX arr: should not hold lock over vnode operation.
*/
-
- /*
- * XXX arr: Should not hold lock over vnode operation.
- */
-
- mtx_lock(&acct_mtx);
if (acctp != NULLVP || savacctp != NULLVP) {
callout_stop(&acctwatch_callout);
error = vn_close((acctp != NULLVP ? acctp : savacctp),
@@ -205,6 +204,7 @@ acct(td, uap)
mtx_unlock(&acct_mtx);
log(LOG_NOTICE, "Accounting enabled\n");
acctwatch(NULL);
+
done2:
mtx_unlock(&Giant);
return (error);
@@ -216,19 +216,18 @@ done2:
* and are enumerated below. (They're also noted in the system
* "acct.h" header file.)
*/
-
int
acct_process(td)
struct thread *td;
{
- struct proc *p = td->td_proc;
struct acct acct;
- struct rusage *r;
struct timeval ut, st, tmp;
- int t, ret;
- struct vnode *vp;
- struct ucred *uc;
struct plimit *newlim, *oldlim;
+ struct proc *p;
+ struct rusage *r;
+ struct ucred *uc;
+ struct vnode *vp;
+ int t, ret;
mtx_lock(&acct_mtx);
@@ -239,6 +238,8 @@ acct_process(td)
return (0);
}
+ p = td->td_proc;
+
/*
* Get process accounting information.
*/
@@ -292,7 +293,7 @@ acct_process(td)
PROC_UNLOCK(p);
/*
- * Write the accounting information to the file.
+ * Finish doing things that require acct_mtx, and release acct_mtx.
*/
uc = crhold(acctcred);
vref(vp);
@@ -310,6 +311,9 @@ acct_process(td)
PROC_UNLOCK(p);
lim_free(oldlim);
+ /*
+ * Write the accounting information to the file.
+ */
VOP_LEASE(vp, td, uc, LEASE_WRITE);
ret = vn_rdwr(UIO_WRITE, vp, (caddr_t)&acct, sizeof (acct),
(off_t)0, UIO_SYSSPACE, IO_APPEND|IO_UNIT, uc, NOCRED,
@@ -374,10 +378,9 @@ acctwatch(a)
mtx_lock(&acct_mtx);
/*
- * XXX arr: Need to fix the issue of holding acct_mtx over
+ * XXX arr: need to fix the issue of holding acct_mtx over
* the below vnode operations.
*/
-
if (savacctp != NULLVP) {
if (savacctp->v_type == VBAD) {
(void) vn_close(savacctp, savacctflags, savacctcred,
OpenPOWER on IntegriCloud