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)
This commit is contained in:
parent
656e679a17
commit
2f6a774be4
@ -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;
|
||||
|
@ -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 *);
|
||||
|
@ -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;
|
||||
|
@ -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 *);
|
||||
|
@ -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,
|
||||
|
@ -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. */
|
||||
|
@ -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)
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 @@ ffs_syncvnode(struct vnode *vp, int waitfor)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user