Print this page
const-ify make segment ops structures
There is no reason to keep the segment ops structures writable.
patch lower-case-segops
*** 54,65 ****
#include <vm/seg_dev.h>
#include <vm/seg_vn.h>
#include <vm/seg_spt.h>
#include <vm/seg_kmem.h>
! extern struct seg_ops segdev_ops; /* needs a header file */
! extern struct seg_ops segspt_shmops; /* needs a header file */
static int
page_valid(struct seg *seg, caddr_t addr)
{
struct segvn_data *svd;
--- 54,65 ----
#include <vm/seg_dev.h>
#include <vm/seg_vn.h>
#include <vm/seg_spt.h>
#include <vm/seg_kmem.h>
! extern const struct seg_ops segdev_ops; /* needs a header file */
! extern const struct seg_ops segspt_shmops; /* needs a header file */
static int
page_valid(struct seg *seg, caddr_t addr)
{
struct segvn_data *svd;
*** 70,84 ****
* Fail if the page doesn't map to a page in the underlying
* mapped file, if an underlying mapped file exists.
*/
vattr.va_mask = AT_SIZE;
if (seg->s_ops == &segvn_ops &&
! SEGOP_GETVP(seg, addr, &vp) == 0 &&
vp != NULL && vp->v_type == VREG &&
VOP_GETATTR(vp, &vattr, 0, CRED(), NULL) == 0) {
u_offset_t size = roundup(vattr.va_size, (u_offset_t)PAGESIZE);
! u_offset_t offset = SEGOP_GETOFFSET(seg, addr);
if (offset >= size)
return (0);
}
--- 70,84 ----
* Fail if the page doesn't map to a page in the underlying
* mapped file, if an underlying mapped file exists.
*/
vattr.va_mask = AT_SIZE;
if (seg->s_ops == &segvn_ops &&
! segop_getvp(seg, addr, &vp) == 0 &&
vp != NULL && vp->v_type == VREG &&
VOP_GETATTR(vp, &vattr, 0, CRED(), NULL) == 0) {
u_offset_t size = roundup(vattr.va_size, (u_offset_t)PAGESIZE);
! u_offset_t offset = segop_getoffset(seg, addr);
if (offset >= size)
return (0);
}
*** 94,104 ****
* Fail if the segment is mapped from /dev/null.
* The key is that the mapping comes from segdev and the
* type is neither MAP_SHARED nor MAP_PRIVATE.
*/
if (seg->s_ops == &segdev_ops &&
! ((SEGOP_GETTYPE(seg, addr) & (MAP_SHARED | MAP_PRIVATE)) == 0))
return (0);
/*
* Fail if the page is a MAP_NORESERVE page that has
* not actually materialized.
--- 94,104 ----
* Fail if the segment is mapped from /dev/null.
* The key is that the mapping comes from segdev and the
* type is neither MAP_SHARED nor MAP_PRIVATE.
*/
if (seg->s_ops == &segdev_ops &&
! ((segop_gettype(seg, addr) & (MAP_SHARED | MAP_PRIVATE)) == 0))
return (0);
/*
* Fail if the page is a MAP_NORESERVE page that has
* not actually materialized.
*** 115,125 ****
* low-order bit that indicates the page is
* actually in memory. If any bits are set,
* then there is backing store for the page.
*/
char incore = 0;
! (void) SEGOP_INCORE(seg, addr, PAGESIZE, &incore);
if (incore == 0)
return (0);
}
return (1);
}
--- 115,125 ----
* low-order bit that indicates the page is
* actually in memory. If any bits are set,
* then there is backing store for the page.
*/
char incore = 0;
! (void) segop_incore(seg, addr, PAGESIZE, &incore);
if (incore == 0)
return (0);
}
return (1);
}
*** 207,222 ****
if ((seg = as_segat(as, page)) == NULL ||
!page_valid(seg, page)) {
AS_LOCK_EXIT(as, &as->a_lock);
return (ENXIO);
}
! SEGOP_GETPROT(seg, page, 0, &prot);
protchanged = 0;
if ((prot & prot_rw) == 0) {
protchanged = 1;
! err = SEGOP_SETPROT(seg, page, PAGESIZE, prot | prot_rw);
if (err == IE_RETRY) {
protchanged = 0;
ASSERT(retrycnt == 0);
retrycnt++;
--- 207,222 ----
if ((seg = as_segat(as, page)) == NULL ||
!page_valid(seg, page)) {
AS_LOCK_EXIT(as, &as->a_lock);
return (ENXIO);
}
! segop_getprot(seg, page, 0, &prot);
protchanged = 0;
if ((prot & prot_rw) == 0) {
protchanged = 1;
! err = segop_setprot(seg, page, PAGESIZE, prot | prot_rw);
if (err == IE_RETRY) {
protchanged = 0;
ASSERT(retrycnt == 0);
retrycnt++;
*** 242,254 ****
else if (seg->s_ops == &segvn_ops)
rw = S_READ_NOCOW;
else
rw = S_READ;
! if (SEGOP_FAULT(as->a_hat, seg, page, PAGESIZE, F_SOFTLOCK, rw)) {
if (protchanged)
! (void) SEGOP_SETPROT(seg, page, PAGESIZE, prot);
AS_LOCK_EXIT(as, &as->a_lock);
return (ENXIO);
}
CPU_STATS_ADD_K(vm, softlock, 1);
--- 242,254 ----
else if (seg->s_ops == &segvn_ops)
rw = S_READ_NOCOW;
else
rw = S_READ;
! if (segop_fault(as->a_hat, seg, page, PAGESIZE, F_SOFTLOCK, rw)) {
if (protchanged)
! (void) segop_setprot(seg, page, PAGESIZE, prot);
AS_LOCK_EXIT(as, &as->a_lock);
return (ENXIO);
}
CPU_STATS_ADD_K(vm, softlock, 1);
*** 301,314 ****
mapout(as, addr, vaddr, writing);
if (rw == S_READ_NOCOW)
rw = S_READ;
! (void) SEGOP_FAULT(as->a_hat, seg, page, PAGESIZE, F_SOFTUNLOCK, rw);
if (protchanged)
! (void) SEGOP_SETPROT(seg, page, PAGESIZE, prot);
AS_LOCK_EXIT(as, &as->a_lock);
return (error);
}
--- 301,314 ----
mapout(as, addr, vaddr, writing);
if (rw == S_READ_NOCOW)
rw = S_READ;
! (void) segop_fault(as->a_hat, seg, page, PAGESIZE, F_SOFTUNLOCK, rw);
if (protchanged)
! (void) segop_setprot(seg, page, PAGESIZE, prot);
AS_LOCK_EXIT(as, &as->a_lock);
return (error);
}