Constify vm_pager-related virtual tables.

Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D30070
This commit is contained in:
Konstantin Belousov 2021-05-04 00:58:07 +03:00
parent 4b8365d752
commit d474440ab3
10 changed files with 33 additions and 32 deletions

View File

@ -327,7 +327,7 @@ shm_largepage_phys_dtor(vm_object_t object)
}
}
static struct phys_pager_ops shm_largepage_phys_ops = {
static const struct phys_pager_ops shm_largepage_phys_ops = {
.phys_pg_populate = shm_largepage_phys_populate,
.phys_pg_haspage = shm_largepage_phys_haspage,
.phys_pg_ctor = shm_largepage_phys_ctor,

View File

@ -70,7 +70,7 @@ static boolean_t default_pager_haspage(vm_object_t, vm_pindex_t, int *,
* On the first request to page out a page from a default object, the
* object is converted to swap pager type.
*/
struct pagerops defaultpagerops = {
const struct pagerops defaultpagerops = {
.pgo_alloc = default_pager_alloc,
.pgo_dealloc = default_pager_dealloc,
.pgo_getpages = default_pager_getpages,

View File

@ -74,7 +74,7 @@ static struct pagerlst dev_pager_object_list;
/* protect list manipulation */
static struct mtx dev_pager_mtx;
struct pagerops devicepagerops = {
const struct pagerops devicepagerops = {
.pgo_init = dev_pager_init,
.pgo_alloc = dev_pager_alloc,
.pgo_dealloc = dev_pager_dealloc,
@ -83,7 +83,7 @@ struct pagerops devicepagerops = {
.pgo_haspage = dev_pager_haspage,
};
struct pagerops mgtdevicepagerops = {
const struct pagerops mgtdevicepagerops = {
.pgo_alloc = dev_pager_alloc,
.pgo_dealloc = dev_pager_dealloc,
.pgo_getpages = dev_pager_getpages,
@ -98,7 +98,7 @@ static void old_dev_pager_dtor(void *handle);
static int old_dev_pager_fault(vm_object_t object, vm_ooffset_t offset,
int prot, vm_page_t *mres);
static struct cdev_pager_ops old_dev_pager_ops = {
static const struct cdev_pager_ops old_dev_pager_ops = {
.cdev_pg_ctor = old_dev_pager_ctor,
.cdev_pg_dtor = old_dev_pager_dtor,
.cdev_pg_fault = old_dev_pager_fault
@ -124,8 +124,9 @@ cdev_pager_lookup(void *handle)
}
vm_object_t
cdev_pager_allocate(void *handle, enum obj_type tp, struct cdev_pager_ops *ops,
vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t foff, struct ucred *cred)
cdev_pager_allocate(void *handle, enum obj_type tp,
const struct cdev_pager_ops *ops, vm_ooffset_t size, vm_prot_t prot,
vm_ooffset_t foff, struct ucred *cred)
{
vm_object_t object, object1;
vm_pindex_t pindex;

View File

@ -57,7 +57,7 @@ static int default_phys_pager_populate(vm_object_t object, vm_pindex_t pidx,
int fault_type, vm_prot_t max_prot, vm_pindex_t *first, vm_pindex_t *last);
static boolean_t default_phys_pager_haspage(vm_object_t object,
vm_pindex_t pindex, int *before, int *after);
struct phys_pager_ops default_phys_pg_ops = {
const struct phys_pager_ops default_phys_pg_ops = {
.phys_pg_getpages = default_phys_pager_getpages,
.phys_pg_populate = default_phys_pager_populate,
.phys_pg_haspage = default_phys_pager_haspage,
@ -74,7 +74,7 @@ phys_pager_init(void)
}
vm_object_t
phys_pager_allocate(void *handle, struct phys_pager_ops *ops, void *data,
phys_pager_allocate(void *handle, const struct phys_pager_ops *ops, void *data,
vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t foff, struct ucred *cred)
{
vm_object_t object, object1;
@ -298,7 +298,7 @@ phys_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before,
before, after));
}
struct pagerops physpagerops = {
const struct pagerops physpagerops = {
.pgo_init = phys_pager_init,
.pgo_alloc = phys_pager_alloc,
.pgo_dealloc = phys_pager_dealloc,

View File

@ -59,7 +59,7 @@ static void sg_pager_putpages(vm_object_t, vm_page_t *, int,
static boolean_t sg_pager_haspage(vm_object_t, vm_pindex_t, int *,
int *);
struct pagerops sgpagerops = {
const struct pagerops sgpagerops = {
.pgo_alloc = sg_pager_alloc,
.pgo_dealloc = sg_pager_dealloc,
.pgo_getpages = sg_pager_getpages,

View File

@ -441,7 +441,7 @@ static void swap_tmpfs_pager_getvp(vm_object_t object, struct vnode **vpp,
static void swap_pager_freespace(vm_object_t object, vm_pindex_t start,
vm_size_t size);
struct pagerops swappagerops = {
const struct pagerops swappagerops = {
.pgo_init = swap_pager_init, /* early system initialization of pager */
.pgo_alloc = swap_pager_alloc, /* allocate an OBJT_SWAP object */
.pgo_dealloc = swap_pager_dealloc, /* deallocate an OBJT_SWAP object */
@ -455,7 +455,7 @@ struct pagerops swappagerops = {
.pgo_freespace = swap_pager_freespace,
};
struct pagerops swaptmpfspagerops = {
const struct pagerops swaptmpfspagerops = {
.pgo_alloc = swap_tmpfs_pager_alloc,
.pgo_dealloc = swap_pager_dealloc,
.pgo_getpages = swap_pager_getpages,

View File

@ -140,7 +140,7 @@ struct vm_object {
*/
struct {
TAILQ_HEAD(, vm_page) devp_pglist;
struct cdev_pager_ops *ops;
const struct cdev_pager_ops *ops;
struct cdev *dev;
} devp;
@ -178,7 +178,7 @@ struct vm_object {
* Phys pager
*/
struct {
struct phys_pager_ops *ops;
const struct phys_pager_ops *ops;
union {
void *data_ptr;
uintptr_t data_val;

View File

@ -154,7 +154,7 @@ dead_pager_getvp(vm_object_t object, struct vnode **vpp, bool *vp_heldp)
*/
}
static struct pagerops deadpagerops = {
static const struct pagerops deadpagerops = {
.pgo_alloc = dead_pager_alloc,
.pgo_dealloc = dead_pager_dealloc,
.pgo_getpages = dead_pager_getpages,
@ -163,7 +163,7 @@ static struct pagerops deadpagerops = {
.pgo_getvp = dead_pager_getvp,
};
struct pagerops *pagertab[] = {
const struct pagerops *pagertab[] __read_mostly = {
[OBJT_DEFAULT] = &defaultpagerops,
[OBJT_SWAP] = &swappagerops,
[OBJT_VNODE] = &vnodepagerops,
@ -178,7 +178,7 @@ struct pagerops *pagertab[] = {
void
vm_pager_init(void)
{
struct pagerops **pgops;
const struct pagerops **pgops;
/*
* Initialize known pagers
@ -244,7 +244,7 @@ vm_pager_allocate(objtype_t type, void *handle, vm_ooffset_t size,
vm_prot_t prot, vm_ooffset_t off, struct ucred *cred)
{
vm_object_t ret;
struct pagerops *ops;
const struct pagerops *ops;
ops = pagertab[type];
if (ops)

View File

@ -88,14 +88,14 @@ struct pagerops {
pgo_freespace_t *pgo_freespace;
};
extern struct pagerops defaultpagerops;
extern struct pagerops swappagerops;
extern struct pagerops vnodepagerops;
extern struct pagerops devicepagerops;
extern struct pagerops physpagerops;
extern struct pagerops sgpagerops;
extern struct pagerops mgtdevicepagerops;
extern struct pagerops swaptmpfspagerops;
extern const struct pagerops defaultpagerops;
extern const struct pagerops swappagerops;
extern const struct pagerops vnodepagerops;
extern const struct pagerops devicepagerops;
extern const struct pagerops physpagerops;
extern const struct pagerops sgpagerops;
extern const struct pagerops mgtdevicepagerops;
extern const struct pagerops swaptmpfspagerops;
/*
* get/put return values
@ -120,7 +120,7 @@ extern struct pagerops swaptmpfspagerops;
#ifdef _KERNEL
extern struct pagerops *pagertab[];
extern const struct pagerops *pagertab[] __read_mostly;
extern struct mtx_padalign pbuf_mtx;
/*
@ -260,7 +260,7 @@ struct cdev_pager_ops {
};
vm_object_t cdev_pager_allocate(void *handle, enum obj_type tp,
struct cdev_pager_ops *ops, vm_ooffset_t size, vm_prot_t prot,
const struct cdev_pager_ops *ops, vm_ooffset_t size, vm_prot_t prot,
vm_ooffset_t foff, struct ucred *cred);
vm_object_t cdev_pager_lookup(void *handle);
void cdev_pager_free_page(vm_object_t object, vm_page_t m);
@ -277,8 +277,8 @@ struct phys_pager_ops {
vm_ooffset_t foff, struct ucred *cred);
void (*phys_pg_dtor)(vm_object_t vm_obj);
};
extern struct phys_pager_ops default_phys_pg_ops;
vm_object_t phys_pager_allocate(void *handle, struct phys_pager_ops *ops,
extern const struct phys_pager_ops default_phys_pg_ops;
vm_object_t phys_pager_allocate(void *handle, const struct phys_pager_ops *ops,
void *data, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t foff,
struct ucred *cred);

View File

@ -107,7 +107,7 @@ static void vnode_pager_release_writecount(vm_object_t, vm_offset_t,
vm_offset_t);
static void vnode_pager_getvp(vm_object_t, struct vnode **, bool *);
struct pagerops vnodepagerops = {
const struct pagerops vnodepagerops = {
.pgo_alloc = vnode_pager_alloc,
.pgo_dealloc = vnode_pager_dealloc,
.pgo_getpages = vnode_pager_getpages,