From nobody Fri Jan 05 05:00:52 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 4T5rrN5HvMz56HXG; Fri, 5 Jan 2024 05:00:52 +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 4T5rrN1gWZz4Wqm; Fri, 5 Jan 2024 05:00:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704430852; 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=iRC5HlHjhmK+YWql2ebsHNuQ2ggs9phFQXoTG1+JrKk=; b=Z8550+wBovz0YdXKrgC5qj5LsvSts/mMdb1t74AzLxq5UEyVTCg6+jsG5cQ/wpAcsj1lLg UsPQkx0TbhysKBqmilDMSeNUzzmxdm9Us6ej6SC2lExwR7PuCkKq3cyUf5YvcV2lRIYS3U tB5APfpt3etu8f4kqJ0pbJsgkwH9mY5Xuzy6RqGdXtC21j84T7G4zs5mgf0Hjf6b+ZA2Vw hI1oOw4JM35mKaNTfWR7gIBdyg5BuF+/bGd+sB+Vr2woLxLT6geT7HOHGheTPSVwU0s7UV B0APQN20jdhMZJle7O/JfvIQnqEnMrccmxbmmKEEs0MndDhWqgQdnfgIkqiijw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704430852; 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=iRC5HlHjhmK+YWql2ebsHNuQ2ggs9phFQXoTG1+JrKk=; b=bj30VbXpLbDYO5ysKow3cxkfOLsjf+uUDusjKPzVumLSTDx26GJu/RShZGraC7Cd+PFfkT yYNCBiNx97T1sYpp2ChWBD01YqAcL9e51qt5vI466ajiGJra7buMhjIDfrez3ojWN2ANLl dJRfmN2aStk4wyhNPvuVgOuz4cAA6pKjZwjwygVr4X7O23eoaLBPSxWRkFo3fR/2+NG6D4 0aogcqT/19k7dL32OelVTLv58LDrXwcndNx+GYhhJf/6qr/KNDTDc5PViTSMfkAzyZbwww LT5vAoGjTKt86zRlpkIX3l/cYF/ZizshlLMfrlXkTpAb5w7Y23rMMDuvLI3jjw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704430852; a=rsa-sha256; cv=none; b=QsDmiGkBcznwuN71Vrz+Oa1mYJSPkistVP8Llx6X+8OzFBXTErLIteMk3HWPcP9z0Q9eX0 oovmdvdssZn6SLVywRlcNGyCkeiGAHIirCYJL0iTEVNjYhJ+s9xQij4M1zy+IBM2AGVtNX 6LFemqDeNO4+AHqVfz63tlGdvCddjT1DWl46FeRYVzVOIpO0h3shIV5pYvvH/e1ptj8ih4 nm+e1qNmgn7Pk4SkMu0jeuvZyXTBoOibtnQkwm72Z35O/dvxIxNtbQS4Xt1R16DiND5lgA 51Kv9EoBPh5m3Z/P5lSqOHMllNzTLWI3A8bcMlaMCuGSnPUEC2gRDGTkxyvo9Q== 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 4T5rrN0nHdzkXK; Fri, 5 Jan 2024 05:00:52 +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 40550qcE090405; Fri, 5 Jan 2024 05:00:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40550qKZ090402; Fri, 5 Jan 2024 05:00:52 GMT (envelope-from git) Date: Fri, 5 Jan 2024 05:00:52 GMT Message-Id: <202401050500.40550qKZ090402@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: 70dc6b2ce314 - main - nfsclient: limit situations when we do unlocked read-ahead by nfsiod 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: 70dc6b2ce314a0f32755005ad02802fca7ed186e Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=70dc6b2ce314a0f32755005ad02802fca7ed186e commit 70dc6b2ce314a0f32755005ad02802fca7ed186e Author: Konstantin Belousov AuthorDate: 2024-01-01 22:22:44 +0000 Commit: Konstantin Belousov CommitDate: 2024-01-05 04:58:58 +0000 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 --- sys/fs/nfsclient/nfs_clbio.c | 11 +++++++++-- 1 file 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) &&