diff options
author | eivind <eivind@FreeBSD.org> | 1999-01-20 14:49:12 +0000 |
---|---|---|
committer | eivind <eivind@FreeBSD.org> | 1999-01-20 14:49:12 +0000 |
commit | 836035a4edf2d12174893117e0db29e309203a8b (patch) | |
tree | b49b8271eedf41e5c0a341956ab5c43489f98b71 | |
parent | af1ac09a53e9b9f7d330522b7109c3ae65dbba61 (diff) | |
download | FreeBSD-src-836035a4edf2d12174893117e0db29e309203a8b.zip FreeBSD-src-836035a4edf2d12174893117e0db29e309203a8b.tar.gz |
Add 'options DEBUG_LOCKS', which stores extra information in struct
lock, and add some macros and function parameters to make sure that
the information get to the point where it can be put in the lock
structure.
While I'm here, add DEBUG_VFS_LOCKS to LINT.
-rw-r--r-- | sys/coda/coda_vnops.c | 12 | ||||
-rw-r--r-- | sys/conf/NOTES | 11 | ||||
-rw-r--r-- | sys/conf/options | 3 | ||||
-rw-r--r-- | sys/fs/coda/coda_vnops.c | 12 | ||||
-rw-r--r-- | sys/i386/conf/LINT | 11 | ||||
-rw-r--r-- | sys/i386/conf/NOTES | 11 | ||||
-rw-r--r-- | sys/kern/kern_lock.c | 26 | ||||
-rw-r--r-- | sys/kern/vfs_default.c | 12 | ||||
-rw-r--r-- | sys/kern/vfs_vnops.c | 17 | ||||
-rw-r--r-- | sys/sys/lock.h | 18 | ||||
-rw-r--r-- | sys/sys/lockmgr.h | 18 | ||||
-rw-r--r-- | sys/sys/vnode.h | 11 |
12 files changed, 149 insertions, 13 deletions
diff --git a/sys/coda/coda_vnops.c b/sys/coda/coda_vnops.c index b401cd3..c0cfa5e 100644 --- a/sys/coda/coda_vnops.c +++ b/sys/coda/coda_vnops.c @@ -27,7 +27,7 @@ * Mellon the rights to redistribute these changes without encumbrance. * * @(#) src/sys/coda/coda_vnops.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $ - * $Id: coda_vnops.c,v 1.11 1999/01/05 18:49:51 eivind Exp $ + * $Id: coda_vnops.c,v 1.12 1999/01/07 16:14:12 bde Exp $ * */ @@ -48,6 +48,11 @@ /* * HISTORY * $Log: coda_vnops.c,v $ + * Revision 1.12 1999/01/07 16:14:12 bde + * Don't pass unused unused timestamp args to UFS_UPDATE() or waste + * time initializing them. This almost finishes centralizing (in-core) + * timestamp updates in ufs_itimes(). + * * Revision 1.11 1999/01/05 18:49:51 eivind * Remove the 'waslocked' parameter to vfs_object_create(). * @@ -2037,7 +2042,12 @@ coda_lock(v) cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique)); } +#ifndef DEBUG_LOCKS return (lockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, p)); +#else + return (debuglockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, p, + "coda_lock", vp->filename, vp->line)); +#endif } int diff --git a/sys/conf/NOTES b/sys/conf/NOTES index e151c09..762e124 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -2,7 +2,7 @@ # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.537 1999/01/19 15:11:46 des Exp $ +# $Id: LINT,v 1.538 1999/01/20 03:29:51 msmith Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -1844,6 +1844,14 @@ options "PMAP_SHPGPERPROC=201" # options "NSFBUFS=1024" +# +# Enable extra debugging code for locks. This include storing the +# filename and line of whatever aquired the lock in the lock itself, +# and changing a number of function calls to pass around the relevant +# data. This is not at all useful unless you are debugging lock code. +# +options DEBUG_LOCKS + # More undocumented options for linting. options CLK_CALIBRATION_LOOP @@ -1853,6 +1861,7 @@ options CLUSTERDEBUG options COMPAT_LINUX options CPU_UPGRADE_HW_CACHE options DEBUG +options DEBUG_VFS_LOCKS options "DEBUG_1284" #options DISABLE_PSE options "EXT2FS" diff --git a/sys/conf/options b/sys/conf/options index 6089840..35ceb1a 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -1,4 +1,4 @@ -# $Id: options,v 1.119 1999/01/15 10:00:10 bde Exp $ +# $Id: options,v 1.120 1999/01/17 19:02:39 peter Exp $ # # On the handling of kernel options # @@ -255,6 +255,7 @@ SI_DEBUG opt_debug_si.h # These cause changes all over the kernel DEBUG opt_global.h +DEBUG_LOCKS opt_global.h DEBUG_VFS_LOCKS opt_global.h DIAGNOSTIC opt_global.h ENABLE_VFS_IOOPT opt_global.h diff --git a/sys/fs/coda/coda_vnops.c b/sys/fs/coda/coda_vnops.c index b401cd3..c0cfa5e 100644 --- a/sys/fs/coda/coda_vnops.c +++ b/sys/fs/coda/coda_vnops.c @@ -27,7 +27,7 @@ * Mellon the rights to redistribute these changes without encumbrance. * * @(#) src/sys/coda/coda_vnops.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $ - * $Id: coda_vnops.c,v 1.11 1999/01/05 18:49:51 eivind Exp $ + * $Id: coda_vnops.c,v 1.12 1999/01/07 16:14:12 bde Exp $ * */ @@ -48,6 +48,11 @@ /* * HISTORY * $Log: coda_vnops.c,v $ + * Revision 1.12 1999/01/07 16:14:12 bde + * Don't pass unused unused timestamp args to UFS_UPDATE() or waste + * time initializing them. This almost finishes centralizing (in-core) + * timestamp updates in ufs_itimes(). + * * Revision 1.11 1999/01/05 18:49:51 eivind * Remove the 'waslocked' parameter to vfs_object_create(). * @@ -2037,7 +2042,12 @@ coda_lock(v) cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique)); } +#ifndef DEBUG_LOCKS return (lockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, p)); +#else + return (debuglockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, p, + "coda_lock", vp->filename, vp->line)); +#endif } int diff --git a/sys/i386/conf/LINT b/sys/i386/conf/LINT index e151c09..762e124 100644 --- a/sys/i386/conf/LINT +++ b/sys/i386/conf/LINT @@ -2,7 +2,7 @@ # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.537 1999/01/19 15:11:46 des Exp $ +# $Id: LINT,v 1.538 1999/01/20 03:29:51 msmith Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -1844,6 +1844,14 @@ options "PMAP_SHPGPERPROC=201" # options "NSFBUFS=1024" +# +# Enable extra debugging code for locks. This include storing the +# filename and line of whatever aquired the lock in the lock itself, +# and changing a number of function calls to pass around the relevant +# data. This is not at all useful unless you are debugging lock code. +# +options DEBUG_LOCKS + # More undocumented options for linting. options CLK_CALIBRATION_LOOP @@ -1853,6 +1861,7 @@ options CLUSTERDEBUG options COMPAT_LINUX options CPU_UPGRADE_HW_CACHE options DEBUG +options DEBUG_VFS_LOCKS options "DEBUG_1284" #options DISABLE_PSE options "EXT2FS" diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index e151c09..762e124 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -2,7 +2,7 @@ # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.537 1999/01/19 15:11:46 des Exp $ +# $Id: LINT,v 1.538 1999/01/20 03:29:51 msmith Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -1844,6 +1844,14 @@ options "PMAP_SHPGPERPROC=201" # options "NSFBUFS=1024" +# +# Enable extra debugging code for locks. This include storing the +# filename and line of whatever aquired the lock in the lock itself, +# and changing a number of function calls to pass around the relevant +# data. This is not at all useful unless you are debugging lock code. +# +options DEBUG_LOCKS + # More undocumented options for linting. options CLK_CALIBRATION_LOOP @@ -1853,6 +1861,7 @@ options CLUSTERDEBUG options COMPAT_LINUX options CPU_UPGRADE_HW_CACHE options DEBUG +options DEBUG_VFS_LOCKS options "DEBUG_1284" #options DISABLE_PSE options "EXT2FS" diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index 0903f6e..e832acf 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -38,7 +38,7 @@ * SUCH DAMAGE. * * @(#)kern_lock.c 8.18 (Berkeley) 5/21/95 - * $Id: kern_lock.c,v 1.21 1999/01/08 17:31:08 eivind Exp $ + * $Id: kern_lock.c,v 1.22 1999/01/10 01:58:24 eivind Exp $ */ #include "opt_lint.h" @@ -171,11 +171,20 @@ acquire(struct lock *lkp, int extflags, int wanted) { * accepted shared locks and shared-to-exclusive upgrades to go away. */ int +#ifndef DEBUG_LOCKS lockmgr(lkp, flags, interlkp, p) +#else +debuglockmgr(lkp, flags, interlkp, p, name, file, line) +#endif struct lock *lkp; u_int flags; struct simplelock *interlkp; struct proc *p; +#ifdef DEBUG_LOCKS + const char *name; /* Name of lock function */ + const char *file; /* Name of file call is from */ + int line; /* Line number in file */ +#endif { int error; pid_t pid; @@ -283,6 +292,11 @@ lockmgr(lkp, flags, interlkp, p) panic("lockmgr: non-zero exclusive count"); #endif lkp->lk_exclusivecount = 1; +#if defined(DEBUG_LOCKS) + lkp->lk_filename = file; + lkp->lk_lineno = line; + lkp->lk_lockername = name; +#endif COUNT(p, 1); break; } @@ -338,6 +352,11 @@ lockmgr(lkp, flags, interlkp, p) panic("lockmgr: non-zero exclusive count"); #endif lkp->lk_exclusivecount = 1; +#if defined(DEBUG_LOCKS) + lkp->lk_filename = file; + lkp->lk_lineno = line; + lkp->lk_lockername = name; +#endif COUNT(p, 1); break; @@ -383,6 +402,11 @@ lockmgr(lkp, flags, interlkp, p) lkp->lk_flags |= LK_DRAINING | LK_HAVE_EXCL; lkp->lk_lockholder = pid; lkp->lk_exclusivecount = 1; +#if defined(DEBUG_LOCKS) + lkp->lk_filename = file; + lkp->lk_lineno = line; + lkp->lk_lockername = name; +#endif COUNT(p, 1); break; diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 47545c3..b73b126 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -205,7 +205,12 @@ vop_stdlock(ap) return 0; } +#ifndef DEBUG_LOCKS return (lockmgr(l, ap->a_flags, &ap->a_vp->v_interlock, ap->a_p)); +#else + return (debuglockmgr(l, ap->a_flags, &ap->a_vp->v_interlock, ap->a_p, + "vop_stdlock", ap->a_vp->filename, ap->a_vp->line)); +#endif } int @@ -355,7 +360,12 @@ vop_sharedlock(ap) } if (flags & LK_INTERLOCK) vnflags |= LK_INTERLOCK; - return(lockmgr(vp->v_vnlock, vnflags, &vp->v_interlock, ap->a_p)); +#ifndef DEBUG_LOCKS + return (lockmgr(vp->v_vnlock, vnflags, &vp->v_interlock, ap->a_p)); +#else + return (debuglockmgr(vp->v_vnlock, vnflags, &vp->v_interlock, ap->a_p, + "vop_sharedlock", vp->filename, vp->line)); +#endif } /* diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 756c945..0b32a7d 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94 - * $Id: vfs_vnops.c,v 1.60 1998/11/02 02:36:16 peter Exp $ + * $Id: vfs_vnops.c,v 1.61 1999/01/05 18:49:56 eivind Exp $ */ #include <sys/param.h> @@ -510,10 +510,18 @@ vn_poll(fp, events, cred, p) * acquire requested lock. */ int +#ifndef DEBUG_LOCKS vn_lock(vp, flags, p) +#else +debug_vn_lock(vp, flags, p, filename, line) +#endif struct vnode *vp; int flags; struct proc *p; +#ifdef DEBUG_LOCKS + const char *filename; + int line; +#endif { int error; @@ -526,7 +534,12 @@ vn_lock(vp, flags, p) tsleep((caddr_t)vp, PINOD, "vn_lock", 0); error = ENOENT; } else { - error = VOP_LOCK(vp, flags | LK_NOPAUSE | LK_INTERLOCK, p); +#ifdef DEBUG_LOCKS + vp->filename = filename; + vp->line = line; +#endif + error = VOP_LOCK(vp, + flags | LK_NOPAUSE | LK_INTERLOCK, p); if (error == 0) return (error); } diff --git a/sys/sys/lock.h b/sys/sys/lock.h index 592a705..c9c287d 100644 --- a/sys/sys/lock.h +++ b/sys/sys/lock.h @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * @(#)lock.h 8.12 (Berkeley) 5/19/95 - * $Id: lock.h,v 1.11 1998/01/06 05:22:48 dyson Exp $ + * $Id: lock.h,v 1.12 1999/01/02 11:34:56 bde Exp $ */ #ifndef _LOCK_H_ @@ -59,6 +59,11 @@ struct lock { char *lk_wmesg; /* resource sleeping (for tsleep) */ int lk_timo; /* maximum sleep time (for tsleep) */ pid_t lk_lockholder; /* pid of exclusive lock holder */ +#ifdef DEBUG_LOCKS + const char *lk_filename; + const char *lk_lockername; + int lk_lineno; +#endif }; /* * Lock request types: @@ -169,8 +174,19 @@ struct proc; void lockinit __P((struct lock *, int prio, char *wmesg, int timo, int flags)); +#ifdef DEBUG_LOCKS +int debuglockmgr __P((struct lock *, u_int flags, + struct simplelock *, struct proc *p, + const char *, + const char *, + int)); +#define lockmgr(lockp, flags, slockp, proc) \ + debuglockmgr((lockp), (flags), (slockp), (proc), \ + "lockmgr", __FILE__, __LINE__) +#else int lockmgr __P((struct lock *, u_int flags, struct simplelock *, struct proc *p)); +#endif void lockmgr_printinfo __P((struct lock *)); int lockstatus __P((struct lock *)); diff --git a/sys/sys/lockmgr.h b/sys/sys/lockmgr.h index 592a705..c9c287d 100644 --- a/sys/sys/lockmgr.h +++ b/sys/sys/lockmgr.h @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * @(#)lock.h 8.12 (Berkeley) 5/19/95 - * $Id: lock.h,v 1.11 1998/01/06 05:22:48 dyson Exp $ + * $Id: lock.h,v 1.12 1999/01/02 11:34:56 bde Exp $ */ #ifndef _LOCK_H_ @@ -59,6 +59,11 @@ struct lock { char *lk_wmesg; /* resource sleeping (for tsleep) */ int lk_timo; /* maximum sleep time (for tsleep) */ pid_t lk_lockholder; /* pid of exclusive lock holder */ +#ifdef DEBUG_LOCKS + const char *lk_filename; + const char *lk_lockername; + int lk_lineno; +#endif }; /* * Lock request types: @@ -169,8 +174,19 @@ struct proc; void lockinit __P((struct lock *, int prio, char *wmesg, int timo, int flags)); +#ifdef DEBUG_LOCKS +int debuglockmgr __P((struct lock *, u_int flags, + struct simplelock *, struct proc *p, + const char *, + const char *, + int)); +#define lockmgr(lockp, flags, slockp, proc) \ + debuglockmgr((lockp), (flags), (slockp), (proc), \ + "lockmgr", __FILE__, __LINE__) +#else int lockmgr __P((struct lock *, u_int flags, struct simplelock *, struct proc *p)); +#endif void lockmgr_printinfo __P((struct lock *)); int lockstatus __P((struct lock *)); diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 3df713e..f5c54b1 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)vnode.h 8.7 (Berkeley) 2/4/94 - * $Id: vnode.h,v 1.78 1998/11/10 09:04:09 peter Exp $ + * $Id: vnode.h,v 1.79 1999/01/05 18:50:01 eivind Exp $ */ #ifndef _SYS_VNODE_H_ @@ -125,6 +125,10 @@ struct vnode { short vpi_events; /* what they are looking for */ short vpi_revents; /* what has happened */ } v_pollinfo; +#ifdef DEBUG_LOCKS + const char *filename; /* Source file doing locking */ + int line; /* Line number doing locking */ +#endif }; #define v_mountedhere v_un.vu_mountedhere #define v_socket v_un.vu_socket @@ -505,6 +509,11 @@ int vrecycle __P((struct vnode *vp, struct simplelock *inter_lkp, int vn_close __P((struct vnode *vp, int flags, struct ucred *cred, struct proc *p)); int vn_lock __P((struct vnode *vp, int flags, struct proc *p)); +#ifdef DEBUG_LOCKS +int debug_vn_lock __P((struct vnode *vp, int flags, struct proc *p, + const char *filename, int line)); +#define vn_lock(vp,flags,p) debug_vn_lock(vp,flags,p,__FILE__,__LINE__) +#endif int vn_open __P((struct nameidata *ndp, int fmode, int cmode)); void vn_pollevent __P((struct vnode *vp, int events)); void vn_pollgone __P((struct vnode *vp)); |