Date: Wed, 17 Jan 2024 10:04:20 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 7b49e60227f8 - stable/14 - ncl_bioread(): check for vp->v_object before accessing it Message-ID: <202401171004.40HA4KRa022924@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7b49e60227f837c9a54c8bfdacd2b352b7e1ded9 commit 7b49e60227f837c9a54c8bfdacd2b352b7e1ded9 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-01-15 11:49:14 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-01-17 10:03:51 +0000 ncl_bioread(): check for vp->v_object before accessing it (cherry picked from commit 503f72a828c7d0d938ec73ffbf62406038c69d47) --- sys/fs/nfsclient/nfs_clbio.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c index 7b9b68782d53..f6b8cc0a70a4 100644 --- a/sys/fs/nfsclient/nfs_clbio.c +++ b/sys/fs/nfsclient/nfs_clbio.c @@ -417,6 +417,18 @@ out: return (error); } +static bool +ncl_bioread_dora(struct vnode *vp) +{ + vm_object_t obj; + + obj = vp->v_object; + if (obj == NULL) + return (true); + return (!vm_object_mightbedirty(vp->v_object) && + vp->v_object->un_pager.vnp.writemappings == 0); +} + /* * Vnode op for read using bio */ @@ -489,9 +501,7 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred) * unlocked read by nfsiod could obliterate changes * done by userspace. */ - if (nmp->nm_readahead > 0 && - !vm_object_mightbedirty(vp->v_object) && - vp->v_object->un_pager.vnp.writemappings == 0) { + if (nmp->nm_readahead > 0 && ncl_bioread_dora(vp)) { for (nra = 0; nra < nmp->nm_readahead && nra < seqcount && (off_t)(lbn + 1 + nra) * biosize < nsize; nra++) { rabn = lbn + 1 + nra; @@ -678,9 +688,7 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred) * directory offset cookie of the next block.) */ NFSLOCKNODE(np); - if (nmp->nm_readahead > 0 && - !vm_object_mightbedirty(vp->v_object) && - vp->v_object->un_pager.vnp.writemappings == 0 && + if (nmp->nm_readahead > 0 && ncl_bioread_dora(vp) && (bp->b_flags & B_INVAL) == 0 && (np->n_direofoffset == 0 || (lbn + 1) * NFS_DIRBLKSIZ < np->n_direofoffset) &&
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401171004.40HA4KRa022924>