summaryrefslogtreecommitdiff
path: root/sys/kern/vfs_vnops.c
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-11-27 05:27:13 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-11-27 05:27:13 +0000
commit8a1845e49f56720cbfccd4c7f5f80ba5b980fdf4 (patch)
treed4a522dc41cdc79ba48fe761e94663b795da8cc0 /sys/kern/vfs_vnops.c
parent0d68e9b5af14f4bfa04d22dbebab5972ac647b26 (diff)
Merge in the unified buffer cache code as found in NetBSD 2001/03/10. The
code is written mostly by Chuck Silvers <chuq@chuq.com>/<chs@netbsd.org>. Tested for the past few weeks by many developers, should be in a pretty stable state, but will require optimizations and additional cleanups.
Diffstat (limited to 'sys/kern/vfs_vnops.c')
-rw-r--r--sys/kern/vfs_vnops.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index ee5eb0baee2..491db1172fa 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_vnops.c,v 1.35 2001/11/15 06:22:30 art Exp $ */
+/* $OpenBSD: vfs_vnops.c,v 1.36 2001/11/27 05:27:12 art Exp $ */
/* $NetBSD: vfs_vnops.c,v 1.20 1996/02/04 02:18:41 christos Exp $ */
/*
@@ -165,6 +165,11 @@ vn_open(ndp, fmode, cmode)
}
if ((error = VOP_OPEN(vp, fmode, cred, p)) != 0)
goto bad;
+ if (vp->v_type == VREG &&
+ uvn_attach(vp, fmode & FWRITE ? VM_PROT_WRITE : 0) == NULL) {
+ error = EIO;
+ goto bad;
+ }
if (fmode & FWRITE)
vp->v_writecount++;
return (0);
@@ -197,11 +202,10 @@ vn_writechk(vp)
}
}
/*
- * If there's shared text associated with
- * the vnode, try to free it up once. If
- * we fail, we can't allow writing.
+ * If the vnode is in use as a process's text,
+ * we can't allow writing.
*/
- if ((vp->v_flag & VTEXT) && !uvm_vnp_uncache(vp))
+ if (vp->v_flag & VTEXT)
return (ETXTBSY);
return (0);
@@ -214,6 +218,23 @@ void
vn_marktext(vp)
struct vnode *vp;
{
+ if ((vp->v_flag & VTEXT) == 0) {
+ uvmexp.vnodepages -= vp->v_uvm.u_obj.uo_npages;
+ uvmexp.vtextpages += vp->v_uvm.u_obj.uo_npages;
+#if 0
+ /*
+ * Doesn't help much because the pager is borked and ubc_flush is
+ * slow.
+ */
+#ifdef PMAP_PREFER
+ /*
+ * Get rid of any cached reads from this vnode.
+ * exec can't respect PMAP_PREFER when mapping the text.
+ */
+ ubc_flush(&vp->v_uvm.u_obj, 0, 0);
+#endif
+#endif
+ }
vp->v_flag |= VTEXT;
}