summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient/nfs_bio.c
diff options
context:
space:
mode:
authorps <ps@FreeBSD.org>2004-12-10 03:27:12 +0000
committerps <ps@FreeBSD.org>2004-12-10 03:27:12 +0000
commitf46c52047f3fcd319847f2c25bb66800bb5d6b2d (patch)
treef9c631fca29de61464b46ce9d29d3fe6c3db1b04 /sys/nfsclient/nfs_bio.c
parentf1047725903546a5213ec64e66e804876ad8f471 (diff)
downloadFreeBSD-src-f46c52047f3fcd319847f2c25bb66800bb5d6b2d.zip
FreeBSD-src-f46c52047f3fcd319847f2c25bb66800bb5d6b2d.tar.gz
Store a hint in the nfsnode to detect sequential access of the file.
Kick off a readahead only when sequential access is detected. This eliminates wasteful readaheads in random file access. Submitted by: Mohan Srinivasan mohans at yahoo-inc dot com Obtained from: Yahoo!
Diffstat (limited to 'sys/nfsclient/nfs_bio.c')
-rw-r--r--sys/nfsclient/nfs_bio.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/nfsclient/nfs_bio.c b/sys/nfsclient/nfs_bio.c
index 9e9af49..c6eea93 100644
--- a/sys/nfsclient/nfs_bio.c
+++ b/sys/nfsclient/nfs_bio.c
@@ -421,8 +421,10 @@ nfs_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
/*
* Start the read ahead(s), as required.
+ * The readahead is kicked off only if sequential access
+ * is detected, based on the readahead hint (ra_expect_lbn).
*/
- if (nmp->nm_readahead > 0) {
+ if (nmp->nm_readahead > 0 && np->ra_expect_lbn == lbn) {
for (nra = 0; nra < nmp->nm_readahead && nra < seqcount &&
(off_t)(lbn + 1 + nra) * biosize < np->n_size; nra++) {
rabn = lbn + 1 + nra;
@@ -448,6 +450,7 @@ nfs_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
}
}
}
+ np->ra_expect_lbn = lbn + 1;
}
/*
OpenPOWER on IntegriCloud