vm_pager: add methods for page insertion and removal notifications
Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37097
This commit is contained in:
parent
d9dc64f158
commit
d537d1f12e
@ -1483,6 +1483,7 @@ vm_page_insert_after(vm_page_t m, vm_object_t object, vm_pindex_t pindex,
|
||||
return (1);
|
||||
}
|
||||
vm_page_insert_radixdone(m, object, mpred);
|
||||
vm_pager_page_inserted(object, m);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -1557,6 +1558,8 @@ vm_page_object_remove(vm_page_t m)
|
||||
if ((m->a.flags & PGA_SWAP_FREE) != 0)
|
||||
vm_pager_page_unswapped(m);
|
||||
|
||||
vm_pager_page_removed(object, m);
|
||||
|
||||
m->object = NULL;
|
||||
mrem = vm_radix_remove(&object->rtree, m->pindex);
|
||||
KASSERT(mrem == m, ("removed page %p, expected page %p", mrem, m));
|
||||
@ -1879,6 +1882,7 @@ vm_page_rename(vm_page_t m, vm_object_t new_object, vm_pindex_t new_pindex)
|
||||
|
||||
vm_page_insert_radixdone(m, new_object, mpred);
|
||||
vm_page_dirty(m);
|
||||
vm_pager_page_inserted(new_object, m);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -430,6 +430,8 @@ vm_pager_alloc_dyn_type(struct pagerops *ops, int base_type)
|
||||
FIX(mightbedirty);
|
||||
FIX(getvp);
|
||||
FIX(freespace);
|
||||
FIX(page_inserted);
|
||||
FIX(page_removed);
|
||||
#undef FIX
|
||||
}
|
||||
pagertab[res] = ops; /* XXXKIB should be rel, but acq is too much */
|
||||
|
@ -69,6 +69,8 @@ typedef void pgo_getvp_t(vm_object_t object, struct vnode **vpp,
|
||||
bool *vp_heldp);
|
||||
typedef void pgo_freespace_t(vm_object_t object, vm_pindex_t start,
|
||||
vm_size_t size);
|
||||
typedef void pgo_page_inserted_t(vm_object_t object, vm_page_t m);
|
||||
typedef void pgo_page_removed_t(vm_object_t object, vm_page_t m);
|
||||
|
||||
struct pagerops {
|
||||
int pgo_kvme_type;
|
||||
@ -87,6 +89,8 @@ struct pagerops {
|
||||
pgo_mightbedirty_t *pgo_mightbedirty;
|
||||
pgo_getvp_t *pgo_getvp;
|
||||
pgo_freespace_t *pgo_freespace;
|
||||
pgo_page_inserted_t *pgo_page_inserted;
|
||||
pgo_page_removed_t *pgo_page_removed;
|
||||
};
|
||||
|
||||
extern const struct pagerops defaultpagerops;
|
||||
@ -249,6 +253,26 @@ vm_pager_freespace(vm_object_t object, vm_pindex_t start,
|
||||
method(object, start, size);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
vm_pager_page_inserted(vm_object_t object, vm_page_t m)
|
||||
{
|
||||
pgo_page_inserted_t *method;
|
||||
|
||||
method = pagertab[object->type]->pgo_page_inserted;
|
||||
if (method != NULL)
|
||||
method(object, m);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
vm_pager_page_removed(vm_object_t object, vm_page_t m)
|
||||
{
|
||||
pgo_page_removed_t *method;
|
||||
|
||||
method = pagertab[object->type]->pgo_page_removed;
|
||||
if (method != NULL)
|
||||
method(object, m);
|
||||
}
|
||||
|
||||
int vm_pager_alloc_dyn_type(struct pagerops *ops, int base_type);
|
||||
void vm_pager_free_dyn_type(objtype_t type);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user