diff options
Diffstat (limited to 'sys/kern/kern_acct.c')
-rw-r--r-- | sys/kern/kern_acct.c | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index fda217a..3362112 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -196,7 +196,7 @@ int sys_acct(struct thread *td, struct acct_args *uap) { struct nameidata nd; - int error, flags, vfslocked, replacing; + int error, flags, replacing; error = priv_check(td, PRIV_ACCT); if (error) @@ -207,30 +207,26 @@ sys_acct(struct thread *td, struct acct_args *uap) * appending and make sure it's a 'normal'. */ if (uap->path != NULL) { - NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE | AUDITVNODE1, + NDINIT(&nd, LOOKUP, NOFOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, td); flags = FWRITE | O_APPEND; error = vn_open(&nd, &flags, 0, NULL); if (error) return (error); - vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); #ifdef MAC error = mac_system_check_acct(td->td_ucred, nd.ni_vp); if (error) { VOP_UNLOCK(nd.ni_vp, 0); vn_close(nd.ni_vp, flags, td->td_ucred, td); - VFS_UNLOCK_GIANT(vfslocked); return (error); } #endif VOP_UNLOCK(nd.ni_vp, 0); if (nd.ni_vp->v_type != VREG) { vn_close(nd.ni_vp, flags, td->td_ucred, td); - VFS_UNLOCK_GIANT(vfslocked); return (EACCES); } - VFS_UNLOCK_GIANT(vfslocked); #ifdef MAC } else { error = mac_system_check_acct(td->td_ucred, NULL); @@ -259,11 +255,8 @@ sys_acct(struct thread *td, struct acct_args *uap) * enabled. */ acct_suspended = 0; - if (acct_vp != NULL) { - vfslocked = VFS_LOCK_GIANT(acct_vp->v_mount); + if (acct_vp != NULL) error = acct_disable(td, !replacing); - VFS_UNLOCK_GIANT(vfslocked); - } if (uap->path == NULL) { if (acct_state & ACCT_RUNNING) { acct_state |= ACCT_EXITREQ; @@ -291,9 +284,7 @@ sys_acct(struct thread *td, struct acct_args *uap) error = kproc_create(acct_thread, NULL, NULL, 0, 0, "accounting"); if (error) { - vfslocked = VFS_LOCK_GIANT(acct_vp->v_mount); (void) vn_close(acct_vp, acct_flags, acct_cred, td); - VFS_UNLOCK_GIANT(vfslocked); crfree(acct_cred); acct_configured = 0; acct_vp = NULL; @@ -346,7 +337,7 @@ acct_process(struct thread *td) struct plimit *newlim, *oldlim; struct proc *p; struct rusage ru; - int t, ret, vfslocked; + int t, ret; /* * Lockless check of accounting condition before doing the hard @@ -442,11 +433,9 @@ acct_process(struct thread *td) /* * Write the accounting information to the file. */ - vfslocked = VFS_LOCK_GIANT(acct_vp->v_mount); ret = vn_rdwr(UIO_WRITE, acct_vp, (caddr_t)&acct, sizeof (acct), (off_t)0, UIO_SYSSPACE, IO_APPEND|IO_UNIT, acct_cred, NOCRED, NULL, td); - VFS_UNLOCK_GIANT(vfslocked); sx_sunlock(&acct_sx); return (ret); } @@ -563,7 +552,6 @@ static void acctwatch(void) { struct statfs sb; - int vfslocked; sx_assert(&acct_sx, SX_XLOCKED); @@ -581,10 +569,8 @@ acctwatch(void) * If our vnode is no longer valid, tear it down and signal the * accounting thread to die. */ - vfslocked = VFS_LOCK_GIANT(acct_vp->v_mount); if (acct_vp->v_type == VBAD) { (void) acct_disable(NULL, 1); - VFS_UNLOCK_GIANT(vfslocked); acct_state |= ACCT_EXITREQ; return; } @@ -593,11 +579,8 @@ acctwatch(void) * Stopping here is better than continuing, maybe it will be VBAD * next time around. */ - if (VFS_STATFS(acct_vp->v_mount, &sb) < 0) { - VFS_UNLOCK_GIANT(vfslocked); + if (VFS_STATFS(acct_vp->v_mount, &sb) < 0) return; - } - VFS_UNLOCK_GIANT(vfslocked); if (acct_suspended) { if (sb.f_bavail > (int64_t)(acctresume * sb.f_blocks / 100)) { |