From nobody Mon Jan 15 15:21:27 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TDG7q2zRXz5791y; Mon, 15 Jan 2024 15:21:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TDG7q2WWXz4rvj; Mon, 15 Jan 2024 15:21:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705332087; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dFpSseDuGBzzFeBh9oRrUHXfRXbnGScRXI7KtjbZsCM=; b=CHiWEwTQ7jyUXZlJkuUMJSvdHxcRsfFlYl4G0VPlr15In0QSHt9shHI1v4vJ7v4pQpAdM7 yyjUmCuoTQvRdDHNkWc8737o93ThsKzJjhdocPFddRWGJlss5dz58iX02PBPsckibKzPdd bdId6k0gX3Q7gLbvbkRMETq49tb+E3y3UA6/blLJhlCB2yt42fMeyvlaYhuKb/FlpLsNXs IK3MfOjHFtVK4Wgtj4CEkgUA/2RQae9RrG6EL+LX2iur8lOv+kxTka4NtWTHZdh0ALMa+J 8F3X9lEnkuO+Hlb16HtsLsklEM4RvwTh5RBTN+rvcxnD5ZLhtVIn7ruKFIxJcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705332087; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dFpSseDuGBzzFeBh9oRrUHXfRXbnGScRXI7KtjbZsCM=; b=tinCgw+Hzca3skjyUBMDWxVRd23UyeRGCUwTUqkDeZkLb47MuJ6kpy1EkEATIouwmQR0kf cfZPN41a5K5FqY4wuyW/BcAfeXDu6DZhntBwoC4YOy7XTqdmix8+WGWMFV7Xaz7gJqGjRc 5ICLuCDO8e7wBkj8UlRYaqN0PzqMDw6s102p3zpCWNCCCsnE8nLy6XZeu09wnPB9QnVx8c CpQtPYwCHAJM1J9f7n+NW3szPumQIG6qMUJ4BBALNOf1df0O4aINZF9QLqJdm4NlISTV8x WsBrefLVy3Uu4fqaml7cZa+tO9rQA6H6yzuIMDoY2tAHD7HovbaMs9j2QUTiQw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705332087; a=rsa-sha256; cv=none; b=uZLVSaMA94BA2gEGiSQ46rWeWdoooMKLgTWXphxSiGGXZkboiKYYfSyyCBRH4h4pjuIcLN 5Z64drsR8Er9xxitDvCKse+i1Wkbj1s3uAbS77FjSTGrAyF1BihF3qsbHkw9ZxYjjPJRh7 a672dHaa2Gq0gN+YSFOzoACXnpptTQshrqWE1v0dE6M3IiwDyqKsbfozL567cqQHhPbcN8 jcHCtNBKBWZA72ceOjFiYsJiTr7CqW44d+JWKGzN1+iBp707B/ZyeEAJppx1A5ZkhAlWXE z6GVgTaEjorWvmT34NS4uAa5XLRG+Ao5bA335ZuztmAnPxyVxeyei4ff6weAGg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TDG7q1c4Mz12Ls; Mon, 15 Jan 2024 15:21:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40FFLR1C003410; Mon, 15 Jan 2024 15:21:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40FFLRtQ003407; Mon, 15 Jan 2024 15:21:27 GMT (envelope-from git) Date: Mon, 15 Jan 2024 15:21:27 GMT Message-Id: <202401151521.40FFLRtQ003407@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 503f72a828c7 - main - ncl_bioread(): check for vp->v_object before accessing it List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 503f72a828c7d0d938ec73ffbf62406038c69d47 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=503f72a828c7d0d938ec73ffbf62406038c69d47 commit 503f72a828c7d0d938ec73ffbf62406038c69d47 Author: Konstantin Belousov AuthorDate: 2024-01-15 11:49:14 +0000 Commit: Konstantin Belousov CommitDate: 2024-01-15 15:19:58 +0000 ncl_bioread(): check for vp->v_object before accessing it Reported by: cy Reviewed by: rmacklem Fixes: 70dc6b2ce314a0f32755005ad02802fca7ed186e MFC after: 3 days --- 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 c027d7d7c3fd..1cf45bb0c924 100644 --- a/sys/fs/nfsclient/nfs_clbio.c +++ b/sys/fs/nfsclient/nfs_clbio.c @@ -414,6 +414,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 */ @@ -486,9 +498,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; @@ -675,9 +685,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) &&