Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/nfs Include checks (under DIAGNOSTIC) to catch vnode loc...



details:   https://anonhg.NetBSD.org/src/rev/fcbe4ddc00d7
branches:  trunk
changeset: 472674:fcbe4ddc00d7
user:      sommerfe <sommerfe%NetBSD.org@localhost>
date:      Tue May 04 16:08:02 1999 +0000

description:
Include checks (under DIAGNOSTIC) to catch vnode lock leaks soon after
they happen (while we still know which remote op is to blame for it),
instead of later when we trip over the already-locked vnode.

diffstat:

 sys/nfs/nfs_syscalls.c |  29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diffs (52 lines):

diff -r e93527ebfb56 -r fcbe4ddc00d7 sys/nfs/nfs_syscalls.c
--- a/sys/nfs/nfs_syscalls.c    Tue May 04 16:01:37 1999 +0000
+++ b/sys/nfs/nfs_syscalls.c    Tue May 04 16:08:02 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_syscalls.c,v 1.33 1998/11/08 15:57:44 mycroft Exp $        */
+/*     $NetBSD: nfs_syscalls.c,v 1.34 1999/05/04 16:08:02 sommerfe Exp $       */
 
 /*
  * Copyright (c) 1989, 1993
@@ -624,8 +624,23 @@
                 * gathered together.
                 */
                do {
+#ifdef DIAGNOSTIC
+                   int lockcount;
+#endif
                    switch (cacherep) {
                    case RC_DOIT:
+#ifdef DIAGNOSTIC
+                       /*
+                        * NFS server procs should neither release
+                        * locks already held, nor leave things
+                        * locked.  Catch this sooner, rather than
+                        * later (when we try to relock something we
+                        * already have locked).  Careful inspection
+                        * of the failing routine usually turns up the
+                        * lock leak.. once we know what it is..
+                        */
+                       lockcount = p->p_locks;
+#endif
                        if (writes_todo || (nd->nd_procnum == NFSPROC_WRITE &&
                            nfsrvw_procrastinate > 0 && !notstarted))
                            error = nfsrv_writegather(&nd, slp,
@@ -633,6 +648,18 @@
                        else
                            error = (*(nfsrv3_procs[nd->nd_procnum]))(nd,
                                slp, nfsd->nfsd_procp, &mreq);
+#ifdef DIAGNOSTIC
+                       if (p->p_locks != lockcount) {
+                               /*
+                                * If you see this panic, audit
+                                * nfsrv3_procs[nd->nd_procnum] for vnode
+                                * locking errors (usually, it's due to
+                                * forgetting to vput() something).
+                                */
+                               panic("nfsd: locking botch in op %d",
+                                   nd ? nd->nd_procnum : -1);
+                       }
+#endif
                        if (mreq == NULL)
                                break;
                        if (error) {



Home | Main Index | Thread Index | Old Index