summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1995-01-09 16:06:02 +0000
committerdg <dg@FreeBSD.org>1995-01-09 16:06:02 +0000
commit1707d41102ca7d645ec2db9e442a27857337d7e9 (patch)
treeafd2f1c13b93c3fff08b58c44153df0d13479824 /sys/nfsclient
parent08ff911ba0fc8f893be057ca25d8b941f6d0f276 (diff)
downloadFreeBSD-src-1707d41102ca7d645ec2db9e442a27857337d7e9.zip
FreeBSD-src-1707d41102ca7d645ec2db9e442a27857337d7e9.tar.gz
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It represents the culmination of over 6 months of R&D. The majority of the merged VM/cache work is by John Dyson. The following highlights the most significant changes. Additionally, there are (mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to support the new VM/buffer scheme. vfs_bio.c: Significant rewrite of most of vfs_bio to support the merged VM buffer cache scheme. The scheme is almost fully compatible with the old filesystem interface. Significant improvement in the number of opportunities for write clustering. vfs_cluster.c, vfs_subr.c Upgrade and performance enhancements in vfs layer code to support merged VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff. vm_object.c: Yet more improvements in the collapse code. Elimination of some windows that can cause list corruption. vm_pageout.c: Fixed it, it really works better now. Somehow in 2.0, some "enhancements" broke the code. This code has been reworked from the ground-up. vm_fault.c, vm_page.c, pmap.c, vm_object.c Support for small-block filesystems with merged VM/buffer cache scheme. pmap.c vm_map.c Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of kernel PTs. vm_glue.c Much simpler and more effective swapping code. No more gratuitous swapping. proc.h Fixed the problem that the p_lock flag was not being cleared on a fork. swap_pager.c, vnode_pager.c Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the code doesn't need it anymore. machdep.c Changes to better support the parameter values for the merged VM/buffer cache scheme. machdep.c, kern_exec.c, vm_glue.c Implemented a seperate submap for temporary exec string space and another one to contain process upages. This eliminates all map fragmentation problems that previously existed. ffs_inode.c, ufs_inode.c, ufs_readwrite.c Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on busy buffers. Submitted by: John Dyson and David Greenman
Diffstat (limited to 'sys/nfsclient')
-rw-r--r--sys/nfsclient/nfs_bio.c49
-rw-r--r--sys/nfsclient/nfs_subs.c55
-rw-r--r--sys/nfsclient/nfs_vnops.c4
3 files changed, 88 insertions, 20 deletions
diff --git a/sys/nfsclient/nfs_bio.c b/sys/nfsclient/nfs_bio.c
index 4d75cf8..4f8fc3e 100644
--- a/sys/nfsclient/nfs_bio.c
+++ b/sys/nfsclient/nfs_bio.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_bio.c 8.5 (Berkeley) 1/4/94
- * $Id: nfs_bio.c,v 1.6 1994/10/02 17:26:55 phk Exp $
+ * $Id: nfs_bio.c,v 1.7 1994/10/17 17:47:32 phk Exp $
*/
#include <sys/param.h>
@@ -78,7 +78,7 @@ nfs_bioread(vp, uio, ioflag, cred)
struct vattr vattr;
struct proc *p;
struct nfsmount *nmp;
- daddr_t lbn, bn, rabn;
+ daddr_t lbn, rabn;
caddr_t baddr;
int got_buf = 0, nra, error = 0, n = 0, on = 0, not_readin;
@@ -94,7 +94,7 @@ nfs_bioread(vp, uio, ioflag, cred)
if (uio->uio_offset < 0 && vp->v_type != VDIR)
return (EINVAL);
nmp = VFSTONFS(vp->v_mount);
- biosize = nmp->nm_rsize;
+ biosize = NFS_MAXDGRAMDATA;
p = uio->uio_procp;
/*
* For nfs, cache consistency can only be maintained approximately.
@@ -198,7 +198,6 @@ nfs_bioread(vp, uio, ioflag, cred)
nfsstats.biocache_reads++;
lbn = uio->uio_offset / biosize;
on = uio->uio_offset & (biosize-1);
- bn = lbn * (biosize / DEV_BSIZE);
not_readin = 1;
/*
@@ -208,15 +207,17 @@ nfs_bioread(vp, uio, ioflag, cred)
lbn == vp->v_lastr + 1) {
for (nra = 0; nra < nmp->nm_readahead &&
(lbn + 1 + nra) * biosize < np->n_size; nra++) {
- rabn = (lbn + 1 + nra) * (biosize / DEV_BSIZE);
+ rabn = lbn + 1 + nra;
if (!incore(vp, rabn)) {
rabp = nfs_getcacheblk(vp, rabn, biosize, p);
if (!rabp)
return (EINTR);
if ((rabp->b_flags & (B_DELWRI | B_DONE)) == 0) {
rabp->b_flags |= (B_READ | B_ASYNC);
+ vfs_busy_pages(rabp, 0);
if (nfs_asyncio(rabp, cred)) {
- rabp->b_flags |= B_INVAL;
+ rabp->b_flags |= B_INVAL|B_ERROR;
+ vfs_unbusy_pages(rabp);
brelse(rabp);
}
}
@@ -230,21 +231,23 @@ nfs_bioread(vp, uio, ioflag, cred)
* Otherwise, get the block and write back/read in,
* as required.
*/
- if ((bp = incore(vp, bn)) &&
+ if ((bp = incore(vp, lbn)) &&
(bp->b_flags & (B_BUSY | B_WRITEINPROG)) ==
(B_BUSY | B_WRITEINPROG))
got_buf = 0;
else {
again:
- bp = nfs_getcacheblk(vp, bn, biosize, p);
+ bp = nfs_getcacheblk(vp, lbn, biosize, p);
if (!bp)
return (EINTR);
got_buf = 1;
if ((bp->b_flags & (B_DONE | B_DELWRI)) == 0) {
bp->b_flags |= B_READ;
not_readin = 0;
+ vfs_busy_pages(bp, 0);
error = nfs_doio(bp, cred, p);
if (error) {
+ vfs_unbusy_pages(bp);
brelse(bp);
return (error);
}
@@ -257,7 +260,7 @@ again:
if (not_readin && n > 0) {
if (on < bp->b_validoff || (on + n) > bp->b_validend) {
if (!got_buf) {
- bp = nfs_getcacheblk(vp, bn, biosize, p);
+ bp = nfs_getcacheblk(vp, lbn, biosize, p);
if (!bp)
return (EINTR);
got_buf = 1;
@@ -285,8 +288,11 @@ again:
return (EINTR);
if ((bp->b_flags & B_DONE) == 0) {
bp->b_flags |= B_READ;
+ vfs_busy_pages(bp, 0);
error = nfs_doio(bp, cred, p);
if (error) {
+ vfs_unbusy_pages(bp);
+ bp->b_flags |= B_ERROR;
brelse(bp);
return (error);
}
@@ -297,14 +303,18 @@ again:
break;
case VDIR:
nfsstats.biocache_readdirs++;
- bn = (daddr_t)uio->uio_offset;
- bp = nfs_getcacheblk(vp, bn, NFS_DIRBLKSIZ, p);
+ lbn = (daddr_t)uio->uio_offset;
+ bp = nfs_getcacheblk(vp, lbn, NFS_DIRBLKSIZ, p);
if (!bp)
return (EINTR);
+
if ((bp->b_flags & B_DONE) == 0) {
bp->b_flags |= B_READ;
+ vfs_busy_pages(bp, 0);
error = nfs_doio(bp, cred, p);
if (error) {
+ vfs_unbusy_pages(bp);
+ bp->b_flags |= B_ERROR;
brelse(bp);
return (error);
}
@@ -323,8 +333,10 @@ again:
if (rabp) {
if ((rabp->b_flags & (B_DONE | B_DELWRI)) == 0) {
rabp->b_flags |= (B_READ | B_ASYNC);
+ vfs_busy_pages(rabp, 0);
if (nfs_asyncio(rabp, cred)) {
- rabp->b_flags |= B_INVAL;
+ vfs_unbusy_pages(rabp);
+ rabp->b_flags |= B_INVAL|B_ERROR;
brelse(rabp);
}
}
@@ -385,7 +397,7 @@ nfs_write(ap)
struct buf *bp;
struct vattr vattr;
struct nfsmount *nmp;
- daddr_t lbn, bn;
+ daddr_t lbn;
int n, on, error = 0;
#ifdef DIAGNOSTIC
@@ -434,14 +446,12 @@ nfs_write(ap)
* will be the same size within a filesystem. nfs_writerpc will
* still use nm_wsize when sizing the rpc's.
*/
- biosize = nmp->nm_rsize;
+ biosize = NFS_MAXDGRAMDATA;
do {
/*
* XXX make sure we aren't cached in the VM page cache
*/
- (void)vnode_pager_uncache(vp);
-
/*
* Check for a valid write lease.
* If non-cachable, just do the rpc
@@ -467,9 +477,8 @@ nfs_write(ap)
lbn = uio->uio_offset / biosize;
on = uio->uio_offset & (biosize-1);
n = min((unsigned)(biosize - on), uio->uio_resid);
- bn = lbn * (biosize / DEV_BSIZE);
again:
- bp = nfs_getcacheblk(vp, bn, biosize, p);
+ bp = nfs_getcacheblk(vp, lbn, biosize, p);
if (!bp)
return (EINTR);
if (bp->b_wcred == NOCRED) {
@@ -591,6 +600,10 @@ nfs_getcacheblk(vp, bn, size, p)
}
} else
bp = getblk(vp, bn, size, 0, 0);
+
+ if( vp->v_type == VREG)
+ bp->b_blkno = (bn * NFS_MAXDGRAMDATA) / DEV_BSIZE;
+
return (bp);
}
diff --git a/sys/nfsclient/nfs_subs.c b/sys/nfsclient/nfs_subs.c
index 9b2ef80..f281360 100644
--- a/sys/nfsclient/nfs_subs.c
+++ b/sys/nfsclient/nfs_subs.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_subs.c 8.3 (Berkeley) 1/4/94
- * $Id: nfs_subs.c,v 1.6 1994/10/02 17:27:01 phk Exp $
+ * $Id: nfs_subs.c,v 1.7 1994/10/17 17:47:37 phk Exp $
*/
/*
@@ -995,6 +995,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, p)
*/
if (cnp->cn_flags & (SAVENAME | SAVESTART)) {
cnp->cn_flags |= HASBUF;
+ nfsrv_vmio( ndp->ni_vp);
return (0);
}
out:
@@ -1123,6 +1124,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp)
*rdonlyp = 0;
if (!lockflag)
VOP_UNLOCK(*vpp);
+ nfsrv_vmio(*vpp);
return (0);
}
@@ -1168,3 +1170,54 @@ netaddr_match(family, haddr, nam)
};
return (0);
}
+
+int
+nfsrv_vmio( struct vnode *vp) {
+ int rtval;
+ vm_object_t object;
+ vm_pager_t pager;
+
+ if( (vp == NULL) || (vp->v_type != VREG))
+ return 1;
+
+retry:
+ if( (vp->v_flag & VVMIO) == 0) {
+ pager = (vm_pager_t) vnode_pager_alloc(vp, 0, 0, 0);
+ object = (vm_object_t) vp->v_vmdata;
+ if( object->pager != pager)
+ panic("nfsrv_vmio: pager/object mismatch");
+ (void) vm_object_lookup( pager);
+ pager_cache( object, TRUE);
+ vp->v_flag |= VVMIO;
+ } else {
+ if( (object = (vm_object_t)vp->v_vmdata) &&
+ (object->flags & OBJ_DEAD)) {
+ tsleep( (caddr_t) object, PVM, "nfdead", 0);
+ goto retry;
+ }
+ if( !object)
+ panic("nfsrv_vmio: VMIO object missing");
+ pager = object->pager;
+ if( !pager)
+ panic("nfsrv_vmio: VMIO pager missing");
+ (void) vm_object_lookup( pager);
+ }
+ return 0;
+}
+int
+nfsrv_vput( struct vnode *vp) {
+ if( (vp->v_flag & VVMIO) && vp->v_vmdata) {
+ vm_object_deallocate( (vm_object_t) vp->v_vmdata);
+ }
+ vput( vp);
+ return 0;
+}
+int
+nfsrv_vrele( struct vnode *vp) {
+ if( (vp->v_flag & VVMIO) && vp->v_vmdata) {
+ vm_object_deallocate( (vm_object_t) vp->v_vmdata);
+ }
+ vrele( vp);
+ return 0;
+}
+
diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c
index 7032a5a..d189a18 100644
--- a/sys/nfsclient/nfs_vnops.c
+++ b/sys/nfsclient/nfs_vnops.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vnops.c 8.5 (Berkeley) 2/13/94
- * $Id: nfs_vnops.c,v 1.9 1994/10/09 07:35:06 davidg Exp $
+ * $Id: nfs_vnops.c,v 1.10 1994/10/17 17:47:41 phk Exp $
*/
/*
@@ -2356,8 +2356,10 @@ nfs_update(ap)
} */ *ap;
{
+#if 0
/* Use nfs_setattr */
printf("nfs_update: need to implement!!");
+#endif
return (EOPNOTSUPP);
}
OpenPOWER on IntegriCloud