Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vnode_pager.c
Show First 20 Lines • Show All 319 Lines • ▼ Show 20 Lines | vnode_pager_dealloc(vm_object_t object) | ||||
object->type = OBJT_DEAD; | object->type = OBJT_DEAD; | ||||
if (object->flags & OBJ_DISCONNECTWNT) { | if (object->flags & OBJ_DISCONNECTWNT) { | ||||
vm_object_clear_flag(object, OBJ_DISCONNECTWNT); | vm_object_clear_flag(object, OBJ_DISCONNECTWNT); | ||||
wakeup(object); | wakeup(object); | ||||
} | } | ||||
ASSERT_VOP_ELOCKED(vp, "vnode_pager_dealloc"); | ASSERT_VOP_ELOCKED(vp, "vnode_pager_dealloc"); | ||||
if (object->un_pager.vnp.writemappings > 0) { | if (object->un_pager.vnp.writemappings > 0) { | ||||
object->un_pager.vnp.writemappings = 0; | object->un_pager.vnp.writemappings = 0; | ||||
VOP_ADD_WRITECOUNT(vp, -1); | VOP_ADD_WRITECOUNT_SUCCEED(vp, -1); | ||||
CTR3(KTR_VFS, "%s: vp %p v_writecount decreased to %d", | CTR3(KTR_VFS, "%s: vp %p v_writecount decreased to %d", | ||||
__func__, vp, vp->v_writecount); | __func__, vp, vp->v_writecount); | ||||
} | } | ||||
vp->v_object = NULL; | vp->v_object = NULL; | ||||
VOP_UNSET_TEXT(vp); | VOP_UNSET_TEXT(vp); | ||||
VM_OBJECT_WUNLOCK(object); | VM_OBJECT_WUNLOCK(object); | ||||
while (refs-- > 0) | while (refs-- > 0) | ||||
vunref(vp); | vunref(vp); | ||||
VM_OBJECT_WLOCK(object); | VM_OBJECT_WLOCK(object); | ||||
markj: Typo in "object". | |||||
} | } | ||||
static boolean_t | static boolean_t | ||||
vnode_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before, | vnode_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before, | ||||
int *after) | int *after) | ||||
{ | { | ||||
struct vnode *vp = object->handle; | struct vnode *vp = object->handle; | ||||
Done Inline ActionsDoes this do the right thing for nullfs vnodes? markj: Does this do the right thing for nullfs vnodes? | |||||
Done Inline ActionsThis occurs on the vnode reclamation, and vgonel() calls vfs_notify_upper(VFS_NOTIFY_UPPER_RECLAIM). So at the time that we zero lower vnode v_writecount, upper (nullfs) vnode is already reclaimed. Note that vp there is always lower vnode, since object->handle is lowervp and e.g. vm_mmap_vnode() specifically re-evaluates vp to get to the lowervp. VOP_SET_TEXT() on nullfs passes the op to lowervp. kib: This occurs on the vnode reclamation, and vgonel() calls vfs_notify_upper… | |||||
daddr_t bn; | daddr_t bn; | ||||
int err; | int err; | ||||
daddr_t reqblock; | daddr_t reqblock; | ||||
int poff; | int poff; | ||||
int bsize; | int bsize; | ||||
int pagesperblock, blocksperpage; | int pagesperblock, blocksperpage; | ||||
VM_OBJECT_ASSERT_WLOCKED(object); | VM_OBJECT_ASSERT_WLOCKED(object); | ||||
▲ Show 20 Lines • Show All 1,155 Lines • ▼ Show 20 Lines | vnode_pager_update_writecount(vm_object_t object, vm_offset_t start, | ||||
if (object->type != OBJT_VNODE) { | if (object->type != OBJT_VNODE) { | ||||
VM_OBJECT_WUNLOCK(object); | VM_OBJECT_WUNLOCK(object); | ||||
return; | return; | ||||
} | } | ||||
old_wm = object->un_pager.vnp.writemappings; | old_wm = object->un_pager.vnp.writemappings; | ||||
object->un_pager.vnp.writemappings += (vm_ooffset_t)end - start; | object->un_pager.vnp.writemappings += (vm_ooffset_t)end - start; | ||||
vp = object->handle; | vp = object->handle; | ||||
if (old_wm == 0 && object->un_pager.vnp.writemappings != 0) { | if (old_wm == 0 && object->un_pager.vnp.writemappings != 0) { | ||||
ASSERT_VOP_ELOCKED(vp, "v_writecount inc"); | ASSERT_VOP_LOCKED(vp, "v_writecount inc"); | ||||
VOP_ADD_WRITECOUNT(vp, 1); | VOP_ADD_WRITECOUNT_SUCCEED(vp, 1); | ||||
CTR3(KTR_VFS, "%s: vp %p v_writecount increased to %d", | CTR3(KTR_VFS, "%s: vp %p v_writecount increased to %d", | ||||
__func__, vp, vp->v_writecount); | __func__, vp, vp->v_writecount); | ||||
} else if (old_wm != 0 && object->un_pager.vnp.writemappings == 0) { | } else if (old_wm != 0 && object->un_pager.vnp.writemappings == 0) { | ||||
ASSERT_VOP_ELOCKED(vp, "v_writecount dec"); | ASSERT_VOP_LOCKED(vp, "v_writecount dec"); | ||||
VOP_ADD_WRITECOUNT(vp, -1); | VOP_ADD_WRITECOUNT_SUCCEED(vp, -1); | ||||
CTR3(KTR_VFS, "%s: vp %p v_writecount decreased to %d", | CTR3(KTR_VFS, "%s: vp %p v_writecount decreased to %d", | ||||
__func__, vp, vp->v_writecount); | __func__, vp, vp->v_writecount); | ||||
} | } | ||||
VM_OBJECT_WUNLOCK(object); | VM_OBJECT_WUNLOCK(object); | ||||
} | } | ||||
void | void | ||||
vnode_pager_release_writecount(vm_object_t object, vm_offset_t start, | vnode_pager_release_writecount(vm_object_t object, vm_offset_t start, | ||||
Show All 25 Lines | if (object->un_pager.vnp.writemappings != inc) { | ||||
return; | return; | ||||
} | } | ||||
vp = object->handle; | vp = object->handle; | ||||
vhold(vp); | vhold(vp); | ||||
VM_OBJECT_WUNLOCK(object); | VM_OBJECT_WUNLOCK(object); | ||||
mp = NULL; | mp = NULL; | ||||
vn_start_write(vp, &mp, V_WAIT); | vn_start_write(vp, &mp, V_WAIT); | ||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); | vn_lock(vp, LK_SHARED | LK_RETRY); | ||||
/* | /* | ||||
* Decrement the object's writemappings, by swapping the start | * Decrement the object's writemappings, by swapping the start | ||||
* and end arguments for vnode_pager_update_writecount(). If | * and end arguments for vnode_pager_update_writecount(). If | ||||
* there was not a race with vnode reclaimation, then the | * there was not a race with vnode reclaimation, then the | ||||
* vnode's v_writecount is decremented. | * vnode's v_writecount is decremented. | ||||
*/ | */ | ||||
vnode_pager_update_writecount(object, end, start); | vnode_pager_update_writecount(object, end, start); | ||||
VOP_UNLOCK(vp, 0); | VOP_UNLOCK(vp, 0); | ||||
vdrop(vp); | vdrop(vp); | ||||
if (mp != NULL) | if (mp != NULL) | ||||
vn_finished_write(mp); | vn_finished_write(mp); | ||||
} | } |
Typo in "object".