summaryrefslogtreecommitdiff
path: root/sys/uvm/uvm_vnode.c
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-08-06 14:03:06 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-08-06 14:03:06 +0000
commit0e51140bc4d8ce922edd65b75fccdcb28c0d7872 (patch)
tree77db98dcab4c639849cf05e5384fc5eab782dd2f /sys/uvm/uvm_vnode.c
parent1b4909669b8582212bdca9564ac3951ad63c336b (diff)
Add a new type voff_t (right now it's typedefed as off_t) used for offsets
into objects. Gives the possibilty to mmap beyond the size of vaddr_t. From NetBSD.
Diffstat (limited to 'sys/uvm/uvm_vnode.c')
-rw-r--r--sys/uvm/uvm_vnode.c82
1 files changed, 34 insertions, 48 deletions
diff --git a/sys/uvm/uvm_vnode.c b/sys/uvm/uvm_vnode.c
index 9dfdbe2c381..a9ba03bd53a 100644
--- a/sys/uvm/uvm_vnode.c
+++ b/sys/uvm/uvm_vnode.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_vnode.c,v 1.16 2001/07/31 13:34:46 art Exp $ */
-/* $NetBSD: uvm_vnode.c,v 1.29 2000/03/13 23:52:42 soren Exp $ */
+/* $OpenBSD: uvm_vnode.c,v 1.17 2001/08/06 14:03:05 art Exp $ */
+/* $NetBSD: uvm_vnode.c,v 1.30 2000/03/26 20:54:47 kleink Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -88,15 +88,15 @@ lock_data_t uvn_sync_lock; /* locks sync operation */
* functions
*/
-static int uvn_asyncget __P((struct uvm_object *, vaddr_t,
+static int uvn_asyncget __P((struct uvm_object *, voff_t,
int));
struct uvm_object *uvn_attach __P((void *, vm_prot_t));
-static void uvn_cluster __P((struct uvm_object *, vaddr_t,
- vaddr_t *, vaddr_t *));
+static void uvn_cluster __P((struct uvm_object *, voff_t,
+ voff_t *, voff_t *));
static void uvn_detach __P((struct uvm_object *));
-static boolean_t uvn_flush __P((struct uvm_object *, vaddr_t,
- vaddr_t, int));
-static int uvn_get __P((struct uvm_object *, vaddr_t,
+static boolean_t uvn_flush __P((struct uvm_object *, voff_t,
+ voff_t, int));
+static int uvn_get __P((struct uvm_object *, voff_t,
vm_page_t *, int *, int,
vm_prot_t, int, int));
static void uvn_init __P((void));
@@ -185,6 +185,8 @@ uvn_attach(arg, accessprot)
*/
simple_lock(&uvn->u_obj.vmobjlock);
while (uvn->u_flags & UVM_VNODE_BLOCKED) {
+ printf("uvn_attach: blocked at 0x%p flags 0x%x\n",
+ uvn, uvn->u_flags);
uvn->u_flags |= UVM_VNODE_WANTED;
UVMHIST_LOG(maphist, " SLEEPING on blocked vn",0,0,0,0);
UVM_UNLOCK_AND_WAIT(uvn, &uvn->u_obj.vmobjlock, FALSE,
@@ -289,13 +291,6 @@ uvn_attach(arg, accessprot)
if (vp->v_type == VBLK)
printf("used_vnode_size = %qu\n", (long long)used_vnode_size);
#endif
- if (used_vnode_size > (vaddr_t) -PAGE_SIZE) {
-#ifdef DEBUG
- printf("uvn_attach: vn %p size truncated %qx->%x\n", vp,
- (long long)used_vnode_size, -PAGE_SIZE);
-#endif
- used_vnode_size = (vaddr_t) -PAGE_SIZE;
- }
/*
* now set up the uvn.
@@ -832,15 +827,15 @@ uvn_releasepg(pg, nextpgp)
static boolean_t
uvn_flush(uobj, start, stop, flags)
struct uvm_object *uobj;
- vaddr_t start, stop;
+ voff_t start, stop;
int flags;
{
struct uvm_vnode *uvn = (struct uvm_vnode *) uobj;
struct vm_page *pp, *ppnext, *ptmp;
struct vm_page *pps[MAXBSIZE >> PAGE_SHIFT], **ppsp;
int npages, result, lcv;
- boolean_t retval, need_iosync, by_list, needs_clean;
- vaddr_t curoff;
+ boolean_t retval, need_iosync, by_list, needs_clean, all;
+ voff_t curoff;
u_short pp_version;
UVMHIST_FUNC("uvn_flush"); UVMHIST_CALLED(maphist);
@@ -852,8 +847,7 @@ uvn_flush(uobj, start, stop, flags)
need_iosync = FALSE;
retval = TRUE; /* return value */
if (flags & PGO_ALLPAGES) {
- start = 0;
- stop = round_page(uvn->u_size);
+ all = TRUE;
by_list = TRUE; /* always go by the list */
} else {
start = trunc_page(start);
@@ -863,6 +857,7 @@ uvn_flush(uobj, start, stop, flags)
printf("uvn_flush: strange, got an out of range "
"flush (fixed)\n");
#endif
+ all = FALSE;
by_list = (uobj->uo_npages <=
((stop - start) >> PAGE_SHIFT) * UVN_HASH_PENALTY);
}
@@ -887,7 +882,8 @@ uvn_flush(uobj, start, stop, flags)
if (by_list) {
for (pp = uobj->memq.tqh_first ; pp != NULL ;
pp = pp->listq.tqe_next) {
- if (pp->offset < start || pp->offset >= stop)
+ if (!all &&
+ (pp->offset < start || pp->offset >= stop))
continue;
pp->flags &= ~PG_CLEANCHK;
}
@@ -929,7 +925,8 @@ uvn_flush(uobj, start, stop, flags)
* range check
*/
- if (pp->offset < start || pp->offset >= stop) {
+ if (!all &&
+ (pp->offset < start || pp->offset >= stop)) {
ppnext = pp->listq.tqe_next;
continue;
}
@@ -1200,9 +1197,10 @@ ReTry:
} else {
if (result != VM_PAGER_OK) {
printf("uvn_flush: obj=%p, "
- "offset=0x%lx. error "
+ "offset=0x%llx. error "
"during pageout.\n",
- pp->uobject, pp->offset);
+ pp->uobject,
+ (long long)pp->offset);
printf("uvn_flush: WARNING: "
"changes to page may be "
"lost!\n");
@@ -1257,8 +1255,8 @@ ReTry:
static void
uvn_cluster(uobj, offset, loffset, hoffset)
struct uvm_object *uobj;
- vaddr_t offset;
- vaddr_t *loffset, *hoffset; /* OUT */
+ voff_t offset;
+ voff_t *loffset, *hoffset; /* OUT */
{
struct uvm_vnode *uvn = (struct uvm_vnode *) uobj;
*loffset = offset;
@@ -1317,13 +1315,13 @@ uvn_put(uobj, pps, npages, flags)
static int
uvn_get(uobj, offset, pps, npagesp, centeridx, access_type, advice, flags)
struct uvm_object *uobj;
- vaddr_t offset;
+ voff_t offset;
struct vm_page **pps; /* IN/OUT */
int *npagesp; /* IN (OUT if PGO_LOCKED) */
int centeridx, advice, flags;
vm_prot_t access_type;
{
- vaddr_t current_offset;
+ voff_t current_offset;
struct vm_page *ptmp;
int lcv, result, gotpages;
boolean_t done;
@@ -1564,7 +1562,7 @@ uvn_get(uobj, offset, pps, npagesp, centeridx, access_type, advice, flags)
static int
uvn_asyncget(uobj, offset, npages)
struct uvm_object *uobj;
- vaddr_t offset;
+ voff_t offset;
int npages;
{
@@ -1594,8 +1592,10 @@ uvn_io(uvn, pps, npages, flags, rw)
struct vnode *vn;
struct uio uio;
struct iovec iov;
- vaddr_t kva, file_offset;
- int waitf, result, got, wanted;
+ vaddr_t kva;
+ off_t file_offset;
+ int waitf, result;
+ size_t got, wanted;
UVMHIST_FUNC("uvn_io"); UVMHIST_CALLED(maphist);
UVMHIST_LOG(maphist, "rw=%d", rw,0,0,0);
@@ -1905,7 +1905,7 @@ uvm_vnp_uncache(vp)
void
uvm_vnp_setsize(vp, newsize)
struct vnode *vp;
- u_quad_t newsize;
+ voff_t newsize;
{
struct uvm_vnode *uvn = &vp->v_uvm;
@@ -1916,29 +1916,15 @@ uvm_vnp_setsize(vp, newsize)
if (uvn->u_flags & UVM_VNODE_VALID) {
/*
- * make sure that the newsize fits within a vaddr_t
- * XXX: need to revise addressing data types
- */
-
- if (newsize > (vaddr_t) -PAGE_SIZE) {
-#ifdef DEBUG
- printf("uvm_vnp_setsize: vn %p size truncated "
- "%qx->%lx\n", vp, (long long)newsize,
- (vaddr_t)-PAGE_SIZE);
-#endif
- newsize = (vaddr_t)-PAGE_SIZE;
- }
-
- /*
* now check if the size has changed: if we shrink we had better
* toss some pages...
*/
if (uvn->u_size > newsize) {
- (void)uvn_flush(&uvn->u_obj, (vaddr_t) newsize,
+ (void)uvn_flush(&uvn->u_obj, newsize,
uvn->u_size, PGO_FREE);
}
- uvn->u_size = (vaddr_t)newsize;
+ uvn->u_size = newsize;
}
simple_unlock(&uvn->u_obj.vmobjlock);