diff options
author | kmacy <kmacy@FreeBSD.org> | 2006-11-13 05:51:22 +0000 |
---|---|---|
committer | kmacy <kmacy@FreeBSD.org> | 2006-11-13 05:51:22 +0000 |
commit | 0c00ea16dbadcde1937dfc2bef577820b762e95a (patch) | |
tree | c2c7577af1d9350da736e5ba02f23f6df8c9f273 /sys | |
parent | c07fe38e024b8eb9ed43c77f898e85cf8c488928 (diff) | |
download | FreeBSD-src-0c00ea16dbadcde1937dfc2bef577820b762e95a.zip FreeBSD-src-0c00ea16dbadcde1937dfc2bef577820b762e95a.tar.gz |
change vop_lock handling to allowing tracking of callers' file and line for
acquisition of lockmgr locks
Approved by: scottl (standing in for mentor rwatson)
Diffstat (limited to 'sys')
-rw-r--r-- | sys/coda/coda_vnops.c | 4 | ||||
-rw-r--r-- | sys/coda/coda_vnops.h | 2 | ||||
-rw-r--r-- | sys/fs/coda/coda_vnops.c | 4 | ||||
-rw-r--r-- | sys/fs/coda/coda_vnops.h | 2 | ||||
-rw-r--r-- | sys/fs/nullfs/null_vnops.c | 4 | ||||
-rw-r--r-- | sys/kern/vfs_default.c | 8 | ||||
-rw-r--r-- | sys/kern/vfs_subr.c | 6 | ||||
-rw-r--r-- | sys/kern/vfs_vnops.c | 7 | ||||
-rw-r--r-- | sys/kern/vnode_if.src | 4 | ||||
-rw-r--r-- | sys/sys/vnode.h | 8 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vnops.c | 20 |
11 files changed, 38 insertions, 31 deletions
diff --git a/sys/coda/coda_vnops.c b/sys/coda/coda_vnops.c index 75de19f..c35dda8 100644 --- a/sys/coda/coda_vnops.c +++ b/sys/coda/coda_vnops.c @@ -129,7 +129,7 @@ struct vop_vector coda_vnodeops = { .vop_readlink = coda_readlink, /* readlink */ .vop_inactive = coda_inactive, /* inactive */ .vop_reclaim = coda_reclaim, /* reclaim */ - .vop_lock = coda_lock, /* lock */ + ._vop_lock = coda_lock, /* lock */ .vop_unlock = coda_unlock, /* unlock */ .vop_bmap = coda_bmap, /* bmap */ .vop_print = VOP_PANIC, /* print */ @@ -1627,7 +1627,7 @@ coda_reclaim(struct vop_reclaim_args *ap) } int -coda_lock(struct vop_lock_args *ap) +coda_lock(struct _vop_lock_args *ap) { /* true args */ struct vnode *vp = ap->a_vp; diff --git a/sys/coda/coda_vnops.h b/sys/coda/coda_vnops.h index db8e3f8..fb79a18 100644 --- a/sys/coda/coda_vnops.h +++ b/sys/coda/coda_vnops.h @@ -72,7 +72,7 @@ vop_readdir_t coda_readdir; vop_bmap_t coda_bmap; vop_strategy_t coda_strategy; vop_reclaim_t coda_reclaim; -vop_lock_t coda_lock; +_vop_lock_t coda_lock; vop_unlock_t coda_unlock; vop_islocked_t coda_islocked; int coda_vop_error(void *); diff --git a/sys/fs/coda/coda_vnops.c b/sys/fs/coda/coda_vnops.c index 75de19f..c35dda8 100644 --- a/sys/fs/coda/coda_vnops.c +++ b/sys/fs/coda/coda_vnops.c @@ -129,7 +129,7 @@ struct vop_vector coda_vnodeops = { .vop_readlink = coda_readlink, /* readlink */ .vop_inactive = coda_inactive, /* inactive */ .vop_reclaim = coda_reclaim, /* reclaim */ - .vop_lock = coda_lock, /* lock */ + ._vop_lock = coda_lock, /* lock */ .vop_unlock = coda_unlock, /* unlock */ .vop_bmap = coda_bmap, /* bmap */ .vop_print = VOP_PANIC, /* print */ @@ -1627,7 +1627,7 @@ coda_reclaim(struct vop_reclaim_args *ap) } int -coda_lock(struct vop_lock_args *ap) +coda_lock(struct _vop_lock_args *ap) { /* true args */ struct vnode *vp = ap->a_vp; diff --git a/sys/fs/coda/coda_vnops.h b/sys/fs/coda/coda_vnops.h index db8e3f8..fb79a18 100644 --- a/sys/fs/coda/coda_vnops.h +++ b/sys/fs/coda/coda_vnops.h @@ -72,7 +72,7 @@ vop_readdir_t coda_readdir; vop_bmap_t coda_bmap; vop_strategy_t coda_strategy; vop_reclaim_t coda_reclaim; -vop_lock_t coda_lock; +_vop_lock_t coda_lock; vop_unlock_t coda_unlock; vop_islocked_t coda_islocked; int coda_vop_error(void *); diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c index f2261f9..4459fe1 100644 --- a/sys/fs/nullfs/null_vnops.c +++ b/sys/fs/nullfs/null_vnops.c @@ -510,7 +510,7 @@ null_rename(struct vop_rename_args *ap) * vnodes below us on the stack. */ static int -null_lock(struct vop_lock_args *ap) +null_lock(struct _vop_lock_args *ap) { struct vnode *vp = ap->a_vp; int flags = ap->a_flags; @@ -719,7 +719,7 @@ struct vop_vector null_vnodeops = { .vop_getwritemount = null_getwritemount, .vop_inactive = null_inactive, .vop_islocked = null_islocked, - .vop_lock = null_lock, + ._vop_lock = null_lock, .vop_lookup = null_lookup, .vop_open = null_open, .vop_print = null_print, diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 0232ff3..38f0e47 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -86,7 +86,7 @@ struct vop_vector default_vnodeops = { .vop_kqfilter = vop_stdkqfilter, .vop_islocked = vop_stdislocked, .vop_lease = VOP_NULL, - .vop_lock = vop_stdlock, + ._vop_lock = vop_stdlock, .vop_lookup = vop_nolookup, .vop_open = VOP_NULL, .vop_pathconf = VOP_EINVAL, @@ -252,15 +252,17 @@ vop_stdpathconf(ap) */ int vop_stdlock(ap) - struct vop_lock_args /* { + struct _vop_lock_args /* { struct vnode *a_vp; int a_flags; struct thread *a_td; + char *file; + int line; } */ *ap; { struct vnode *vp = ap->a_vp; - return (lockmgr(vp->v_vnlock, ap->a_flags, VI_MTX(vp), ap->a_td)); + return (_lockmgr(vp->v_vnlock, ap->a_flags, VI_MTX(vp), ap->a_td, ap->a_file, ap->a_line)); } /* See above. */ diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index b9a65da..e860b1b 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -2994,7 +2994,7 @@ static struct vop_vector sync_vnodeops = { .vop_fsync = sync_fsync, /* fsync */ .vop_inactive = sync_inactive, /* inactive */ .vop_reclaim = sync_reclaim, /* reclaim */ - .vop_lock = vop_stdlock, /* lock */ + ._vop_lock = vop_stdlock, /* lock */ .vop_unlock = vop_stdunlock, /* unlock */ .vop_islocked = vop_stdislocked, /* islocked */ }; @@ -3498,7 +3498,7 @@ void vop_lock_pre(void *ap) { #ifdef DEBUG_VFS_LOCKS - struct vop_lock_args *a = ap; + struct _vop_lock_args *a = ap; if ((a->a_flags & LK_INTERLOCK) == 0) ASSERT_VI_UNLOCKED(a->a_vp, "VOP_LOCK"); @@ -3511,7 +3511,7 @@ void vop_lock_post(void *ap, int rc) { #ifdef DEBUG_VFS_LOCKS - struct vop_lock_args *a = ap; + struct _vop_lock_args *a = ap; ASSERT_VI_UNLOCKED(a->a_vp, "VOP_LOCK"); if (rc == 0) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 3511044..c56d7fc 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -799,10 +799,7 @@ vn_poll(fp, events, active_cred, td) * acquire requested lock. */ int -vn_lock(vp, flags, td) - struct vnode *vp; - int flags; - struct thread *td; +_vn_lock(struct vnode *vp, int flags, struct thread *td, char *file, int line) { int error; @@ -825,7 +822,7 @@ vn_lock(vp, flags, td) * lockmgr drops interlock before it will return for * any reason. So force the code above to relock it. */ - error = VOP_LOCK(vp, flags | LK_INTERLOCK, td); + error = _VOP_LOCK(vp, flags | LK_INTERLOCK, td, file, line); flags &= ~LK_INTERLOCK; KASSERT((flags & LK_RETRY) == 0 || error == 0, ("LK_RETRY set with incompatible flags %d\n", flags)); diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index 5b2c4cb..e3b338b 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -365,10 +365,12 @@ vop_reclaim { %! lock pre vop_lock_pre %! lock post vop_lock_post -vop_lock { +_vop_lock { IN struct vnode *vp; IN int flags; IN struct thread *td; + IN char *file; + IN int line; }; diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 2bd0971..d877ab9 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -606,7 +606,8 @@ int vn_close(struct vnode *vp, void vn_finished_write(struct mount *mp); void vn_finished_secondary_write(struct mount *mp); int vn_isdisk(struct vnode *vp, int *errp); -int vn_lock(struct vnode *vp, int flags, struct thread *td); +int _vn_lock(struct vnode *vp, int flags, struct thread *td, char *file, int line); +#define vn_lock(vp, flags, td) _vn_lock(vp, flags, td, __FILE__, __LINE__) int vn_open(struct nameidata *ndp, int *flagp, int cmode, int fdidx); int vn_open_cred(struct nameidata *ndp, int *flagp, int cmode, struct ucred *cred, int fdidx); @@ -644,7 +645,7 @@ int vop_stdgetpages(struct vop_getpages_args *); int vop_stdinactive(struct vop_inactive_args *); int vop_stdislocked(struct vop_islocked_args *); int vop_stdkqfilter(struct vop_kqfilter_args *); -int vop_stdlock(struct vop_lock_args *); +int vop_stdlock(struct _vop_lock_args *); int vop_stdputpages(struct vop_putpages_args *); int vop_stdunlock(struct vop_unlock_args *); int vop_nopoll(struct vop_poll_args *); @@ -697,6 +698,9 @@ void vop_unlock_pre(void *a); | (noffset > osize ? NOTE_EXTEND : 0)); \ } +#define VOP_LOCK(vp, flags, td) _VOP_LOCK(vp, flags, td, __FILE__, __LINE__) + + void vput(struct vnode *vp); void vrele(struct vnode *vp); void vref(struct vnode *vp); diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 5ffedd7..3ebadeb 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -104,7 +104,7 @@ __FBSDID("$FreeBSD$"); extern int ffs_rawread(struct vnode *vp, struct uio *uio, int *workdone); #endif static vop_fsync_t ffs_fsync; -static vop_lock_t ffs_lock; +static _vop_lock_t ffs_lock; static vop_getpages_t ffs_getpages; static vop_read_t ffs_read; static vop_write_t ffs_write; @@ -125,7 +125,7 @@ struct vop_vector ffs_vnodeops1 = { .vop_default = &ufs_vnodeops, .vop_fsync = ffs_fsync, .vop_getpages = ffs_getpages, - .vop_lock = ffs_lock, + ._vop_lock = ffs_lock, .vop_read = ffs_read, .vop_reallocblks = ffs_reallocblks, .vop_write = ffs_write, @@ -142,7 +142,7 @@ struct vop_vector ffs_vnodeops2 = { .vop_default = &ufs_vnodeops, .vop_fsync = ffs_fsync, .vop_getpages = ffs_getpages, - .vop_lock = ffs_lock, + ._vop_lock = ffs_lock, .vop_read = ffs_read, .vop_reallocblks = ffs_reallocblks, .vop_write = ffs_write, @@ -157,7 +157,7 @@ struct vop_vector ffs_vnodeops2 = { struct vop_vector ffs_fifoops2 = { .vop_default = &ufs_fifoops, .vop_fsync = ffs_fsync, - .vop_lock = ffs_lock, + ._vop_lock = ffs_lock, .vop_reallocblks = ffs_reallocblks, .vop_strategy = ffsext_strategy, .vop_closeextattr = ffs_closeextattr, @@ -333,10 +333,12 @@ loop: static int ffs_lock(ap) - struct vop_lock_args /* { + struct _vop_lock_args /* { struct vnode *a_vp; int a_flags; struct thread *a_td; + char *file; + int line; } */ *ap; { #ifndef NO_FFS_SNAPSHOT @@ -363,7 +365,7 @@ ffs_lock(ap) flags |= LK_INTERLOCK; } lkp = vp->v_vnlock; - result = lockmgr(lkp, flags, VI_MTX(vp), ap->a_td); + result = _lockmgr(lkp, flags, VI_MTX(vp), ap->a_td, ap->a_file, ap->a_line); if (lkp == vp->v_vnlock || result != 0) break; /* @@ -374,18 +376,18 @@ ffs_lock(ap) * right lock. Release it, and try to get the * new lock. */ - (void) lockmgr(lkp, LK_RELEASE, VI_MTX(vp), ap->a_td); + (void) _lockmgr(lkp, LK_RELEASE, VI_MTX(vp), ap->a_td, ap->a_file, ap->a_line); if ((flags & LK_TYPE_MASK) == LK_UPGRADE) flags = (flags & ~LK_TYPE_MASK) | LK_EXCLUSIVE; flags &= ~LK_INTERLOCK; } break; default: - result = VOP_LOCK_APV(&ufs_vnodeops, ap); + result = _VOP_LOCK_APV(&ufs_vnodeops, ap); } return (result); #else - return (VOP_LOCK_APV(&ufs_vnodeops, ap)); + return (_VOP_LOCK_APV(&ufs_vnodeops, ap)); #endif } |