diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2024-01-01 22:22:44 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2024-01-05 04:58:58 +0000 |
| commit | 70dc6b2ce314a0f32755005ad02802fca7ed186e (patch) | |
| tree | 7e01688b98f870f20be21fc74384251a95f42625 /sys | |
| parent | 2d33ad48bd37f27925e4c46c798f8f2d23a2b501 (diff) | |
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/fs/nfsclient/nfs_clbio.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c index e6486af55daf..f6506e34ee59 100644 --- a/sys/fs/nfsclient/nfs_clbio.c +++ b/sys/fs/nfsclient/nfs_clbio.c @@ -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) && |
