Make the segment lock aware of LWPs. Fixes a (somewhat confusing)

"lockmgr: pid 3997, not exclusive lockholder 3997, unlocking" panic I
encountered while running blogbench on an LFS.
This commit is contained in:
perseant 2006-04-07 23:44:14 +00:00
parent 712aacb6d4
commit d28248e84e
2 changed files with 12 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs.h,v 1.97 2006/03/24 20:05:32 perseant Exp $ */
/* $NetBSD: lfs.h,v 1.98 2006/04/07 23:44:14 perseant Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -768,6 +768,7 @@ struct lfs {
struct vnode *lfs_ivnode; /* vnode for the ifile */
u_int32_t lfs_seglock; /* single-thread the segment writer */
pid_t lfs_lockpid; /* pid of lock holder */
lwpid_t lfs_locklwp; /* lwp of lock holder */
u_int32_t lfs_iocount; /* number of ios pending */
u_int32_t lfs_writer; /* don't allow any dirops to start */
u_int32_t lfs_dirops; /* count of active directory ops */
@ -1059,7 +1060,9 @@ struct lfs_fcntl_markv {
#ifdef _KERNEL
/* XXX MP */
#define LFS_SEGLOCK_HELD(fs) \
((fs)->lfs_seglock != 0 && (fs)->lfs_lockpid == curproc->p_pid)
((fs)->lfs_seglock != 0 && \
(fs)->lfs_lockpid == curproc->p_pid && \
(fs)->lfs_locklwp == curlwp->l_lid)
#endif /* _KERNEL */
/* Debug segment lock */

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_subr.c,v 1.57 2006/03/24 20:05:32 perseant Exp $ */
/* $NetBSD: lfs_subr.c,v 1.58 2006/04/07 23:44:14 perseant Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.57 2006/03/24 20:05:32 perseant Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.58 2006/04/07 23:44:14 perseant Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -297,7 +297,8 @@ lfs_seglock(struct lfs *fs, unsigned long flags)
simple_lock(&fs->lfs_interlock);
if (fs->lfs_seglock) {
if (fs->lfs_lockpid == curproc->p_pid) {
if (fs->lfs_lockpid == curproc->p_pid &&
fs->lfs_locklwp == curlwp->l_lid) {
simple_unlock(&fs->lfs_interlock);
++fs->lfs_seglock;
fs->lfs_sp->seg_flags |= flags;
@ -315,6 +316,7 @@ lfs_seglock(struct lfs *fs, unsigned long flags)
fs->lfs_seglock = 1;
fs->lfs_lockpid = curproc->p_pid;
fs->lfs_locklwp = curlwp->l_lid;
simple_unlock(&fs->lfs_interlock);
fs->lfs_cleanind = 0;
@ -509,6 +511,7 @@ lfs_segunlock(struct lfs *fs)
simple_lock(&fs->lfs_interlock);
--fs->lfs_seglock;
fs->lfs_lockpid = 0;
fs->lfs_locklwp = 0;
simple_unlock(&fs->lfs_interlock);
wakeup(&fs->lfs_seglock);
}
@ -552,6 +555,7 @@ lfs_segunlock(struct lfs *fs)
simple_lock(&fs->lfs_interlock);
--fs->lfs_seglock;
fs->lfs_lockpid = 0;
fs->lfs_locklwp = 0;
simple_unlock(&fs->lfs_interlock);
wakeup(&fs->lfs_seglock);
}