summaryrefslogtreecommitdiffstats
path: root/sys/nfs/nfs_bio.c
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>1999-09-17 05:57:57 +0000
committerdillon <dillon@FreeBSD.org>1999-09-17 05:57:57 +0000
commit581716d4dfa79a615e2d311e2da0b1eca85bb5b6 (patch)
treeca5c480c585acbc3d10eb3b4ab470a7596253dbb /sys/nfs/nfs_bio.c
parent4c1e280de7db1d524317194a371a5d246f0f5cfa (diff)
downloadFreeBSD-src-581716d4dfa79a615e2d311e2da0b1eca85bb5b6.zip
FreeBSD-src-581716d4dfa79a615e2d311e2da0b1eca85bb5b6.tar.gz
Asynchronized client-side nfs_commit. NFS commit operations were
previously issued synchronously even if async daemons (nfsiod's) were available. The commit has been moved from the strategy code to the doio code in order to asynchronize it. Removed use of lastr in preparation for removal of vnode->v_lastr. It has been replaced with seqcount, which is already supported by the system and, in fact, gives us a better heuristic for sequential detection then lastr ever did. Made major performance improvements to the server side commit. The server previously fsync'd the entire file for each commit rpc. The server now bawrite()s only those buffers related to the offset/size specified in the commit rpc. Note that we do not commit the meta-data yet. This works still needs to be done. Note that a further optimization can be done (and has not yet been done) on the client: we can merge multiple potential commit rpc's into a single rpc with a greater file offset/size range and greatly reduce rpc traffic. Reviewed by: Alan Cox <alc@cs.rice.edu>, David Greenman <dg@root.com>
Diffstat (limited to 'sys/nfs/nfs_bio.c')
-rw-r--r--sys/nfs/nfs_bio.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/sys/nfs/nfs_bio.c b/sys/nfs/nfs_bio.c
index 1dad3c4..9adaa14 100644
--- a/sys/nfs/nfs_bio.c
+++ b/sys/nfs/nfs_bio.c
@@ -339,6 +339,7 @@ nfs_bioread(vp, uio, ioflag, cred)
struct nfsmount *nmp = VFSTONFS(vp->v_mount);
daddr_t lbn, rabn;
int bcount;
+ int seqcount;
int nra, error = 0, n = 0, on = 0;
#ifdef DIAGNOSTIC
@@ -350,6 +351,7 @@ nfs_bioread(vp, uio, ioflag, cred)
if (uio->uio_offset < 0) /* XXX VDIR cookies can be negative */
return (EINVAL);
p = uio->uio_procp;
+
if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 &&
(nmp->nm_state & NFSSTA_GOTFSINFO) == 0)
(void)nfs_fsinfo(nmp, vp, cred, p);
@@ -357,6 +359,7 @@ nfs_bioread(vp, uio, ioflag, cred)
(uio->uio_offset + uio->uio_resid) > nmp->nm_maxfilesize)
return (EFBIG);
biosize = vp->v_mount->mnt_stat.f_iosize;
+ seqcount = (int)((off_t)(ioflag >> 16) * biosize / BKVASIZE);
/*
* For nfs, cache consistency can only be maintained approximately.
* Although RFC1094 does not specify the criteria, the following is
@@ -455,7 +458,7 @@ nfs_bioread(vp, uio, ioflag, cred)
* Start the read ahead(s), as required.
*/
if (nfs_numasync > 0 && nmp->nm_readahead > 0) {
- for (nra = 0; nra < nmp->nm_readahead &&
+ for (nra = 0; nra < nmp->nm_readahead && nra < seqcount &&
(off_t)(lbn + 1 + nra) * biosize < np->n_size; nra++) {
rabn = lbn + 1 + nra;
if (!incore(vp, rabn)) {
@@ -521,8 +524,6 @@ nfs_bioread(vp, uio, ioflag, cred)
n = 0;
if (on < bcount)
n = min((unsigned)(bcount - on), uio->uio_resid);
-
- vp->v_lastr = lbn;
break;
case VLNK:
nfsstats.biocache_readlinks++;
@@ -1344,6 +1345,35 @@ nfs_doio(bp, cr, p)
bp->b_error = error;
}
} else {
+ /*
+ * If we only need to commit, try to commit
+ */
+ if (bp->b_flags & B_NEEDCOMMIT) {
+ int retv;
+ off_t off;
+
+ off = ((u_quad_t)bp->b_blkno) * DEV_BSIZE + bp->b_dirtyoff;
+ bp->b_flags |= B_WRITEINPROG;
+ retv = nfs_commit(
+ bp->b_vp, off, bp->b_dirtyend-bp->b_dirtyoff,
+ bp->b_wcred, p);
+ bp->b_flags &= ~B_WRITEINPROG;
+ if (retv == 0) {
+ bp->b_dirtyoff = bp->b_dirtyend = 0;
+ bp->b_flags &= ~B_NEEDCOMMIT;
+ bp->b_resid = 0;
+ biodone(bp);
+ return (0);
+ }
+ if (retv == NFSERR_STALEWRITEVERF) {
+ nfs_clearcommit(bp->b_vp->v_mount);
+ }
+ }
+
+ /*
+ * Setup for actual write
+ */
+
if ((off_t)bp->b_blkno * DEV_BSIZE + bp->b_dirtyend > np->n_size)
bp->b_dirtyend = np->n_size - (off_t)bp->b_blkno * DEV_BSIZE;
OpenPOWER on IntegriCloud