diff options
author | Jeff Roberson <jeff@FreeBSD.org> | 2002-08-04 10:29:36 +0000 |
---|---|---|
committer | Jeff Roberson <jeff@FreeBSD.org> | 2002-08-04 10:29:36 +0000 |
commit | e6e370a7fe930e04cec38bcc2e06be127ed7ee02 (patch) | |
tree | e889f56910bf98cbee3be239655a9e4bbb928b2e /sys/vm/vnode_pager.c | |
parent | f75bb0aa25847511ed461bccb4d3fc247ab6b1d5 (diff) | |
download | src-e6e370a7fe930e04cec38bcc2e06be127ed7ee02.tar.gz src-e6e370a7fe930e04cec38bcc2e06be127ed7ee02.zip |
- Replace v_flag with v_iflag and v_vflag
- v_vflag is protected by the vnode lock and is used when synchronization
with VOP calls is needed.
- v_iflag is protected by interlock and is used for dealing with vnode
management issues. These flags include X/O LOCK, FREE, DOOMED, etc.
- All accesses to v_iflag and v_vflag have either been locked or marked with
mp_fixme's.
- Many ASSERT_VOP_LOCKED calls have been added where the locking was not
clear.
- Many functions in vfs_subr.c were restructured to provide for stronger
locking.
Idea stolen from: BSD/OS
Notes
Notes:
svn path=/head/; revision=101308
Diffstat (limited to 'sys/vm/vnode_pager.c')
-rw-r--r-- | sys/vm/vnode_pager.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index 30f069a9e6c7..68a47d05f39e 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -125,11 +125,13 @@ vnode_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, * Prevent race condition when allocating the object. This * can happen with NFS vnodes since the nfsnode isn't locked. */ - while (vp->v_flag & VOLOCK) { - vp->v_flag |= VOWANT; - tsleep(vp, PVM, "vnpobj", 0); + VI_LOCK(vp); + while (vp->v_iflag & VI_OLOCK) { + vp->v_iflag |= VI_OWANT; + msleep(vp, VI_MTX(vp), PVM, "vnpobj", 0); } - vp->v_flag |= VOLOCK; + vp->v_iflag |= VI_OLOCK; + VI_UNLOCK(vp); /* * If the object is being terminated, wait for it to @@ -156,12 +158,14 @@ vnode_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, } else { object->ref_count++; } + VI_LOCK(vp); vp->v_usecount++; - vp->v_flag &= ~VOLOCK; - if (vp->v_flag & VOWANT) { - vp->v_flag &= ~VOWANT; + vp->v_iflag &= ~VI_OLOCK; + if (vp->v_iflag & VI_OWANT) { + vp->v_iflag &= ~VI_OWANT; wakeup(vp); } + VI_UNLOCK(vp); mtx_unlock(&Giant); return (object); } @@ -180,8 +184,9 @@ vnode_pager_dealloc(object) object->handle = NULL; object->type = OBJT_DEAD; + ASSERT_VOP_LOCKED(vp, "vnode_pager_dealloc"); vp->v_object = NULL; - vp->v_flag &= ~(VTEXT | VOBJBUF); + vp->v_vflag &= ~(VV_TEXT | VV_OBJBUF); } static boolean_t @@ -204,9 +209,12 @@ vnode_pager_haspage(object, pindex, before, after) * If no vp or vp is doomed or marked transparent to VM, we do not * have the page. */ - if ((vp == NULL) || (vp->v_flag & VDOOMED)) + if (vp == NULL) return FALSE; + mp_fixme("Unlocked iflags access"); + if (vp->v_iflag & VI_DOOMED) + return FALSE; /* * If filesystem no longer mounted or offset beyond end of file we do * not have the page. |