diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 191bb7cd4900..46f411fd020f 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -118,7 +118,7 @@ exit1(struct thread *td, int rv) struct ucred *tracecred; #endif struct plimit *plim; - int refcnt; + int locked, refcnt; /* * Drop Giant if caller has it. Eventually we should warn about @@ -303,13 +303,13 @@ exit1(struct thread *td, int rv) vm_map_max(&vm->vm_map)); } - mtx_lock(&Giant); sx_xlock(&proctree_lock); if (SESS_LEADER(p)) { struct session *sp; sp = p->p_session; if (sp->s_ttyvp) { + locked = VFS_LOCK_GIANT(sp->s_ttyvp->v_mount); /* * Controlling process. * Signal foreground pgrp, @@ -355,6 +355,7 @@ exit1(struct thread *td, int rv) * that the session once had a controlling terminal. * (for logging and informational purposes) */ + VFS_UNLOCK_GIANT(locked); } SESS_LOCK(p->p_session); sp->s_leader = NULL; @@ -363,7 +364,6 @@ exit1(struct thread *td, int rv) fixjobc(p, p->p_pgrp, 0); sx_xunlock(&proctree_lock); (void)acct_process(td); - mtx_unlock(&Giant); #ifdef KTRACE /* * release trace file @@ -378,9 +378,9 @@ exit1(struct thread *td, int rv) mtx_unlock(&ktrace_mtx); PROC_UNLOCK(p); if (tracevp != NULL) { - mtx_lock(&Giant); + locked = VFS_LOCK_GIANT(tracevp->v_mount); vrele(tracevp); - mtx_unlock(&Giant); + VFS_UNLOCK_GIANT(locked); } if (tracecred != NULL) crfree(tracecred); @@ -390,9 +390,9 @@ exit1(struct thread *td, int rv) */ if ((vtmp = p->p_textvp) != NULL) { p->p_textvp = NULL; - mtx_lock(&Giant); + locked = VFS_LOCK_GIANT(vtmp->v_mount); vrele(vtmp); - mtx_unlock(&Giant); + VFS_UNLOCK_GIANT(locked); } /*