From 4fa649df8e8c28fa780f4f98874fbd70e8d32c4a Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Mon, 31 May 2004 16:32:49 +0000 Subject: [PATCH] Add an assertion that nfssvc() isn't called with Giant. Add two additional pairs of assertions, one at the end of the NFS server event loop, and one one exit from the NFS daemon, that assert that if debug.mpsafenet is enabled, Giant is not held, and that if it is not enabled, Giant will be held. This is intended to support debugging scenarios where Giant is "leaked" during NFS processing. --- sys/nfsserver/nfs_syscalls.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/nfsserver/nfs_syscalls.c b/sys/nfsserver/nfs_syscalls.c index 5a6e2e5fb86..3c6bd562c80 100644 --- a/sys/nfsserver/nfs_syscalls.c +++ b/sys/nfsserver/nfs_syscalls.c @@ -134,6 +134,8 @@ nfssvc(struct thread *td, struct nfssvc_args *uap) struct nfsd_args nfsdarg; int error; + KASSERT(!mtx_owned(&Giant), ("nfssvc(): called with Giant")); + #ifdef MAC error = mac_check_system_nfsd(td->td_ucred); if (error) @@ -550,8 +552,16 @@ nfssvc_nfsd(struct thread *td) nfsd->nfsd_slp = NULL; nfsrv_slpderef(slp); } + KASSERT(!(debug_mpsafenet == 0 && !mtx_owned(&Giant)), + ("nfssvc_nfsd(): debug.mpsafenet=0 && !Giant")); + KASSERT(!(debug_mpsafenet == 1 && mtx_owned(&Giant)), + ("nfssvc_nfsd(): debug.mpsafenet=1 && Giant")); } done: + KASSERT(!(debug_mpsafenet == 0 && !mtx_owned(&Giant)), + ("nfssvc_nfsd(): debug.mpsafenet=0 && !Giant")); + KASSERT(!(debug_mpsafenet == 1 && mtx_owned(&Giant)), + ("nfssvc_nfsd(): debug.mpsafenet=1 && Giant")); TAILQ_REMOVE(&nfsd_head, nfsd, nfsd_chain); splx(s); free((caddr_t)nfsd, M_NFSD);