Subject: Re: simple_lock: uninitialized lock
To: Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de>
From: Antti Kantee <pooka@netbsd.org>
List: current-users
Date: 07/24/2007 14:14:07
Well I whipped up a better patch.  It touches lockmgr to drain without
marking the lock drained.  living on the edge etcetc.

Index: kern/vfs_subr.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_subr.c,v
retrieving revision 1.291
diff -p -u -r1.291 vfs_subr.c
--- kern/vfs_subr.c	17 Jul 2007 21:14:05 -0000	1.291
+++ kern/vfs_subr.c	24 Jul 2007 11:08:17 -0000
@@ -1535,7 +1535,7 @@ vclean(struct vnode *vp, int flags, stru
 	 * We don't drain the lock because it might have been exported
 	 * to upper layers by this vnode and could still be in use.
 	 */
-	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.
Index: kern/kern_lock.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_lock.c,v
retrieving revision 1.116
diff -p -u -r1.116 kern_lock.c
--- kern/kern_lock.c	18 Jun 2007 21:37:32 -0000	1.116
+++ kern/kern_lock.c	24 Jul 2007 11:08:18 -0000
@@ -917,7 +917,9 @@ lockmgr(volatile struct lock *lkp, u_int
 		    RETURN_ADDRESS);
 		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_num);
 #if defined(LOCKDEBUG)
 		lkp->lk_lock_file = file;
Index: sys/lock.h
===================================================================
RCS file: /cvsroot/src/sys/sys/lock.h,v
retrieving revision 1.71
diff -p -u -r1.71 lock.h
--- sys/lock.h	17 May 2007 14:51:42 -0000	1.71
+++ sys/lock.h	24 Jul 2007 11:08:18 -0000
@@ -229,7 +229,7 @@ struct lock {
  * 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 */
@@ -237,6 +237,7 @@ struct lock {
 #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.
  *

-- 
Antti Kantee <pooka@iki.fi>                     Of course he runs NetBSD
http://www.iki.fi/pooka/                          http://www.NetBSD.org/
    "la qualité la plus indispensable du cuisinier est l'exactitude"