Permit vm_pager_has_page() to run with a shared lock. Introduce

VM_OBJECT_DROP/VM_OBJECT_PICKUP to handle functions that are called with
uncertain lock state.

Reviewed by:	kib, markj
Tested by:	pho
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21310
This commit is contained in:
Jeff Roberson 2019-08-19 22:25:28 +00:00
parent 8a3238521b
commit 4153054a7c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=351235
3 changed files with 9 additions and 4 deletions

View File

@ -255,6 +255,10 @@ extern struct vm_object kernel_object_store;
rw_wowned(&(object)->lock)
#define VM_OBJECT_WUNLOCK(object) \
rw_wunlock(&(object)->lock)
#define VM_OBJECT_DROP(object) \
lock_class_rw.lc_unlock(&(object)->lock.lock_object)
#define VM_OBJECT_PICKUP(object, state) \
lock_class_rw.lc_lock(&(object)->lock.lock_object, (state))
struct vnode;

View File

@ -151,7 +151,7 @@ vm_pager_has_page(
) {
boolean_t ret;
VM_OBJECT_ASSERT_WLOCKED(object);
VM_OBJECT_ASSERT_LOCKED(object);
ret = (*pagertab[object->type]->pgo_haspage)
(object, offset, before, after);
return (ret);

View File

@ -355,13 +355,14 @@ vnode_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before,
{
struct vnode *vp = object->handle;
daddr_t bn;
uintptr_t lockstate;
int err;
daddr_t reqblock;
int poff;
int bsize;
int pagesperblock, blocksperpage;
VM_OBJECT_ASSERT_WLOCKED(object);
VM_OBJECT_ASSERT_LOCKED(object);
/*
* If no vp or vp is doomed or marked transparent to VM, we do not
* have the page.
@ -384,9 +385,9 @@ vnode_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before,
blocksperpage = (PAGE_SIZE / bsize);
reqblock = pindex * blocksperpage;
}
VM_OBJECT_WUNLOCK(object);
lockstate = VM_OBJECT_DROP(object);
err = VOP_BMAP(vp, reqblock, NULL, &bn, after, before);
VM_OBJECT_WLOCK(object);
VM_OBJECT_PICKUP(object, lockstate);
if (err)
return TRUE;
if (bn == -1)