mirror of
https://github.com/opnsense/src.git
synced 2026-06-04 14:26:03 -04:00
nfsclient: limit situations when we do unlocked read-ahead by nfsiod
If there were or are writeable mappings, read-ahead might overwrite the dirty pages data that is not yet reflected as a delayed write in the matching buffer state. Noted by: rmacklem Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week
This commit is contained in:
parent
2d33ad48bd
commit
70dc6b2ce3
1 changed files with 9 additions and 2 deletions
|
|
@ -481,9 +481,14 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
|
|||
on = uio->uio_offset - (lbn * biosize);
|
||||
|
||||
/*
|
||||
* Start the read ahead(s), as required.
|
||||
* Start the read ahead(s), as required. Do not do
|
||||
* read-ahead if there are writeable mappings, since
|
||||
* unlocked read by nfsiod could obliterate changes
|
||||
* done by userspace.
|
||||
*/
|
||||
if (nmp->nm_readahead > 0) {
|
||||
if (nmp->nm_readahead > 0 &&
|
||||
!vm_object_mightbedirty(vp->v_object) &&
|
||||
vp->v_object->un_pager.vnp.writemappings == 0) {
|
||||
for (nra = 0; nra < nmp->nm_readahead && nra < seqcount &&
|
||||
(off_t)(lbn + 1 + nra) * biosize < nsize; nra++) {
|
||||
rabn = lbn + 1 + nra;
|
||||
|
|
@ -671,6 +676,8 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
|
|||
*/
|
||||
NFSLOCKNODE(np);
|
||||
if (nmp->nm_readahead > 0 &&
|
||||
!vm_object_mightbedirty(vp->v_object) &&
|
||||
vp->v_object->un_pager.vnp.writemappings == 0 &&
|
||||
(bp->b_flags & B_INVAL) == 0 &&
|
||||
(np->n_direofoffset == 0 ||
|
||||
(lbn + 1) * NFS_DIRBLKSIZ < np->n_direofoffset) &&
|
||||
|
|
|
|||
Loading…
Reference in a new issue