diff options
author | attilio <attilio@FreeBSD.org> | 2008-01-24 12:34:30 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2008-01-24 12:34:30 +0000 |
commit | 7213f4c32b94b60add6400f4213c1ca347bd609f (patch) | |
tree | c29223c268b9510bd1f4bee082ad1de97c817c24 /sys/kern | |
parent | 5671b69e5898140ead9c08fe7f302dde1d680c63 (diff) | |
download | FreeBSD-src-7213f4c32b94b60add6400f4213c1ca347bd609f.zip FreeBSD-src-7213f4c32b94b60add6400f4213c1ca347bd609f.tar.gz |
Cleanup lockmgr interface and exported KPI:
- Remove the "thread" argument from the lockmgr() function as it is
always curthread now
- Axe lockcount() function as it is no longer used
- Axe LOCKMGR_ASSERT() as it is bogus really and no currently used.
Hopefully this will be soonly replaced by something suitable for it.
- Remove the prototype for dumplockinfo() as the function is no longer
present
Addictionally:
- Introduce a KASSERT() in lockstatus() in order to let it accept only
curthread or NULL as they should only be passed
- Do a little bit of style(9) cleanup on lockmgr.h
KPI results heavilly broken by this change, so manpages and
FreeBSD_version will be modified accordingly by further commits.
Tested by: matteo
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_lock.c | 31 | ||||
-rw-r--r-- | sys/kern/vfs_default.c | 7 | ||||
-rw-r--r-- | sys/kern/vfs_mount.c | 6 | ||||
-rw-r--r-- | sys/kern/vfs_subr.c | 4 |
4 files changed, 15 insertions, 33 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index 5ce5ffd..a13dcc7 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -189,23 +189,18 @@ acquire(struct lock **lkpp, int extflags, int wanted, int *contested, uint64_t * * accepted shared locks and shared-to-exclusive upgrades to go away. */ int -_lockmgr(struct lock *lkp, u_int flags, struct mtx *interlkp, - struct thread *td, char *file, int line) +_lockmgr(struct lock *lkp, u_int flags, struct mtx *interlkp, char *file, + int line) { + struct thread *td; int error; int extflags, lockflags; int contested = 0; uint64_t waitstart = 0; - /* - * Lock owner can only be curthread in order to have a deadlock - * free implementation of the primitive. - */ - KASSERT(td == curthread, - ("lockmgr: owner thread (%p) cannot differ from curthread", td)); - error = 0; + td = curthread; if ((flags & LK_INTERNAL) == 0) mtx_lock(lkp->lk_interlock); @@ -576,6 +571,9 @@ lockstatus(lkp, td) int lock_type = 0; int interlocked; + KASSERT(td == NULL || td == curthread, + ("%s: thread passed argument (%p) is not valid", __func__, td)); + if (!kdb_active) { interlocked = 1; mtx_lock(lkp->lk_interlock); @@ -594,21 +592,6 @@ lockstatus(lkp, td) } /* - * Determine the number of holders of a lock. - */ -int -lockcount(lkp) - struct lock *lkp; -{ - int count; - - mtx_lock(lkp->lk_interlock); - count = lkp->lk_exclusivecount + lkp->lk_sharecount; - mtx_unlock(lkp->lk_interlock); - return (count); -} - -/* * Determine the number of waiters on a lock. */ int diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 26d5640..4648f3a 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -263,8 +263,8 @@ vop_stdlock(ap) { struct vnode *vp = ap->a_vp; - return (_lockmgr(vp->v_vnlock, ap->a_flags, VI_MTX(vp), curthread, - ap->a_file, ap->a_line)); + return (_lockmgr(vp->v_vnlock, ap->a_flags, VI_MTX(vp), ap->a_file, + ap->a_line)); } /* See above. */ @@ -278,8 +278,7 @@ vop_stdunlock(ap) { struct vnode *vp = ap->a_vp; - return (lockmgr(vp->v_vnlock, ap->a_flags | LK_RELEASE, VI_MTX(vp), - curthread)); + return (lockmgr(vp->v_vnlock, ap->a_flags | LK_RELEASE, VI_MTX(vp))); } /* See above. */ diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 5100f73..146f868 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -1239,7 +1239,7 @@ dounmount(mp, flags, td) if (flags & MNT_FORCE) mp->mnt_kern_flag |= MNTK_UNMOUNTF; error = lockmgr(&mp->mnt_lock, LK_DRAIN | LK_INTERLOCK | - ((flags & MNT_FORCE) ? 0 : LK_NOWAIT), MNT_MTX(mp), td); + ((flags & MNT_FORCE) ? 0 : LK_NOWAIT), MNT_MTX(mp)); if (error) { MNT_ILOCK(mp); mp->mnt_kern_flag &= ~(MNTK_UNMOUNT | MNTK_NOINSMNTQ | @@ -1314,7 +1314,7 @@ dounmount(mp, flags, td) mp->mnt_flag |= async_flag; if ((mp->mnt_flag & MNT_ASYNC) != 0 && mp->mnt_noasync == 0) mp->mnt_kern_flag |= MNTK_ASYNC; - lockmgr(&mp->mnt_lock, LK_RELEASE, NULL, td); + lockmgr(&mp->mnt_lock, LK_RELEASE, NULL); if (mp->mnt_kern_flag & MNTK_MWAIT) wakeup(mp); MNT_IUNLOCK(mp); @@ -1330,7 +1330,7 @@ dounmount(mp, flags, td) vput(coveredvp); } vfs_event_signal(NULL, VQ_UNMOUNT, 0); - lockmgr(&mp->mnt_lock, LK_RELEASE, NULL, td); + lockmgr(&mp->mnt_lock, LK_RELEASE, NULL); vfs_mount_destroy(mp); return (0); } diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 2fe63b0..8095974 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -361,7 +361,7 @@ vfs_busy(struct mount *mp, int flags, struct mtx *interlkp, if (interlkp) mtx_unlock(interlkp); lkflags = LK_SHARED | LK_INTERLOCK; - if (lockmgr(&mp->mnt_lock, lkflags, MNT_MTX(mp), td)) + if (lockmgr(&mp->mnt_lock, lkflags, MNT_MTX(mp))) panic("vfs_busy: unexpected lock failure"); return (0); } @@ -373,7 +373,7 @@ void vfs_unbusy(struct mount *mp, struct thread *td) { - lockmgr(&mp->mnt_lock, LK_RELEASE, NULL, td); + lockmgr(&mp->mnt_lock, LK_RELEASE, NULL); vfs_rel(mp); } |