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!
This commit is contained in:
parent
02a85ee096
commit
4342aac774
@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -434,6 +434,7 @@ nfs_open(struct vop_open_args *ap)
|
||||
np->n_mtime = vattr.va_mtime;
|
||||
}
|
||||
}
|
||||
np->ra_expect_lbn = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -126,6 +126,7 @@ struct nfsnode {
|
||||
struct nfs4_fctx n_wfc;
|
||||
u_char *n_name; /* leaf name, for v4 OPEN op */
|
||||
uint32_t n_namelen;
|
||||
daddr_t ra_expect_lbn;
|
||||
};
|
||||
|
||||
#define n_atim n_un1.nf_atim
|
||||
|
Loading…
Reference in New Issue
Block a user