Source-Changes-HG archive

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

[src/netbsd-2]: src/sys Pull up following revision(s) (requested by pooka in ...



details:   https://anonhg.NetBSD.org/src/rev/96c0b8e2aaa2
branches:  netbsd-2
changeset: 564604:96c0b8e2aaa2
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sat Aug 11 14:03:47 2007 +0000

description:
Pull up following revision(s) (requested by pooka in ticket #11349):
        sys/sys/lock.h: revision 1.72
        sys/kern/kern_lock.c: revision 1.118 via patch
        sys/kern/vfs_subr.c: revision 1.295
Define a new lockmgr flag LK_RESURRECT which can be used in
conjunction with LK_DRAIN.  This has the same effect as LK_DRAIN
except it atomically does NOT mark the lock as drained.  This
guarantees that when we got the lock, we were the last one currently
waiting for the lock.
Use LK_DRAIN|LK_RESURRECT in vclean() to make sure there are no
waiters for the lock.  This should fix behaviour theoretized to be
caused by vfs_subr.c 1.289 which caused vclean() to run into
completion and free the vnode before all lock-waiters had been
processed.  Should therefore fix the "simple_lock: unitialized lock"
problems seen recently.
thanks to Juergen Hannken-Illjes for some analysis of the problem
and Erik Bertelsen for testing

diffstat:

 sys/kern/kern_lock.c |   8 +++++---
 sys/kern/vfs_subr.c  |  14 +++++++++-----
 sys/sys/lock.h       |   5 +++--
 3 files changed, 17 insertions(+), 10 deletions(-)

diffs (91 lines):

diff -r 2aae0c18ecb3 -r 96c0b8e2aaa2 sys/kern/kern_lock.c
--- a/sys/kern/kern_lock.c      Sat Aug 11 13:58:23 2007 +0000
+++ b/sys/kern/kern_lock.c      Sat Aug 11 14:03:47 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_lock.c,v 1.75.2.1 2004/08/23 05:59:27 tron Exp $  */
+/*     $NetBSD: kern_lock.c,v 1.75.2.1.2.1 2007/08/11 14:03:48 bouyer Exp $    */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.75.2.1 2004/08/23 05:59:27 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.75.2.1.2.1 2007/08/11 14:03:48 bouyer Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_lockdebug.h"
@@ -821,7 +821,9 @@
                    LK_SHARE_NONZERO | LK_WAIT_NONZERO);
                if (error)
                        break;
-               lkp->lk_flags |= LK_DRAINING | LK_HAVE_EXCL;
+               lkp->lk_flags |= LK_HAVE_EXCL;
+               if ((extflags & LK_RESURRECT) == 0)
+                       lkp->lk_flags |= LK_DRAINING;
                SETHOLDER(lkp, pid, lid, cpu_id);
 #if defined(LOCKDEBUG)
                lkp->lk_lock_file = file;
diff -r 2aae0c18ecb3 -r 96c0b8e2aaa2 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c       Sat Aug 11 13:58:23 2007 +0000
+++ b/sys/kern/vfs_subr.c       Sat Aug 11 14:03:47 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_subr.c,v 1.218.2.4.2.2 2007/08/11 13:58:23 bouyer Exp $    */
+/*     $NetBSD: vfs_subr.c,v 1.218.2.4.2.3 2007/08/11 14:03:48 bouyer Exp $    */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.218.2.4.2.2 2007/08/11 13:58:23 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.218.2.4.2.3 2007/08/11 14:03:48 bouyer Exp $");
 
 #include "opt_inet.h"
 #include "opt_ddb.h"
@@ -1607,10 +1607,14 @@
         * active vnodes, it ensures that no other activity can
         * occur while the underlying object is being cleaned out.
         *
-        * We don't drain the lock because it might have been exported
-        * to upper layers by this vnode and could still be in use.
+        * We drain the lock to make sure we are the last one trying to
+        * get it and immediately resurrect the lock.  Future accesses
+        * for locking this _vnode_ will be protected by VXLOCK.  However,
+        * upper layers might be using the _lock_ in case the file system
+        * exported it and might access it while the vnode lingers in
+        * deadfs.
         */
-       VOP_LOCK(vp, LK_EXCLUSIVE | LK_INTERLOCK);
+       VOP_LOCK(vp, LK_DRAIN | LK_RESURRECT | LK_INTERLOCK);
 
        /*
         * Clean out any cached data associated with the vnode.
diff -r 2aae0c18ecb3 -r 96c0b8e2aaa2 sys/sys/lock.h
--- a/sys/sys/lock.h    Sat Aug 11 13:58:23 2007 +0000
+++ b/sys/sys/lock.h    Sat Aug 11 14:03:47 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lock.h,v 1.52.2.1 2004/07/02 18:18:27 he Exp $ */
+/*     $NetBSD: lock.h,v 1.52.2.1.2.1 2007/08/11 14:03:47 bouyer Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -227,7 +227,7 @@
  * or passed in as arguments to the lock manager. The LK_REENABLE flag may be
  * set only at the release of a lock obtained by drain.
  */
-#define        LK_EXTFLG_MASK  0x00700070      /* mask of external flags */
+#define        LK_EXTFLG_MASK  0x00f00070      /* mask of external flags */
 #define        LK_NOWAIT       0x00000010      /* do not sleep to await lock */
 #define        LK_SLEEPFAIL    0x00000020      /* sleep, then return failure */
 #define        LK_CANRECURSE   0x00000040      /* this may be recursive lock attempt */
@@ -235,6 +235,7 @@
 #define        LK_SETRECURSE   0x00100000      /* other locks while we have it OK */
 #define        LK_RECURSEFAIL  0x00200000      /* attempt at recursive lock fails */
 #define        LK_SPIN         0x00400000      /* lock spins instead of sleeps */
+#define        LK_RESURRECT    0x00800000      /* immediately reenable drained lock */
 /*
  * Internal lock flags.
  *



Home | Main Index | Thread Index | Old Index