From nobody Mon Dec 20 21:13:28 2021 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 B2C161903EE6; Mon, 20 Dec 2021 21:13:28 +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 4JHskw2nG4z3GMG; Mon, 20 Dec 2021 21:13:28 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 3F5341D3EF; Mon, 20 Dec 2021 21:13:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BKLDSqA018255; Mon, 20 Dec 2021 21:13:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BKLDSE7018254; Mon, 20 Dec 2021 21:13:28 GMT (envelope-from git) Date: Mon, 20 Dec 2021 21:13:28 GMT Message-Id: <202112202113.1BKLDSE7018254@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: b70042adfebb - main - nfscl: Check for mmap(2)'d file before doing direct output 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: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b70042adfebbc4ee90d6a88dd6dc34d3f8ed5c37 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640034808; 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=5EXwXhFhn3cbCX+w466wH/DmiY63ddwEmrt1kJxQiYA=; b=fGZ6IEljy537Mz2Uj/4StXS+uhKY9jHMpSApzAdwSzlHGxkJ111XxZzTwF6+o5WNgd4POw Pk9ON8TjoqVHu5HBWPBFazRhp97W7BL/wdy0HIWyZvIMKF/N1/rOeSCA4E7oAqCK8xyMFH jFUaurPqTE7WLDQqw2FqxRZCzz2/Uoz5YPPv5zTsJPFtYJXcIg7YCdroCkI3r+qbWGViiZ AL6xiqbiLlXWZ9o7xIU9i4YwZCqNqx3k+0fDefL7FNlXCRQF+jQqJfG3ZUIAUPPD3/6hvL 3xsOMU0WgH9zPACfvfdTkeLxN5TMQvq/4pxMJ6hy58A0F1iaWsYx6B13SXvzbQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640034808; a=rsa-sha256; cv=none; b=QOkqNNaGif5pPqASGk/LODYd+TI6rsldSEC0FrVqrAbuPtlVGRnAekk4nhDYuzk5gEP8NN JNzMv2n5z/nrtXDVkFAjbUsdwClQ12H4RWg2yIdyAL2ovMBxlgo5HenRhKabzMNOmVF+vZ iCgf1h/6+sevmyE867lgCjlwkVVsbDCA8ct695Q/TMHWriiKu1WuCfE2KVJcD6ZIXo4gKR kxkiB2Encb3dUGH+mjDHXlL54fBbbydrFEa2520fnk7Y1ygmoKOP/uYT4U45te2bwCL2PS 9L/uxqsL/wJG6PoYlzlyK1DcbLjun1xE7k5K4Tcl4fcxVQYM3lHVYCKx+/lk+g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=b70042adfebbc4ee90d6a88dd6dc34d3f8ed5c37 commit b70042adfebbc4ee90d6a88dd6dc34d3f8ed5c37 Author: Rick Macklem AuthorDate: 2021-12-20 21:08:51 +0000 Commit: Rick Macklem CommitDate: 2021-12-20 21:10:26 +0000 nfscl: Check for mmap(2)'d file before doing direct output Commit 867c27c23a5c modified the NFS client so that it does IO_APPEND writes directly to the NFS server, bypassing the buffer cache. However, this could result in stale data in client pages when the file is mmap(2)'d. As such, the NFS client needs to call vm_object_is_active() to check if the file is mmap(2)'d and only do direct output if the file is not mmap(2)'d. This patch adds this check. Although a simple patch, I have given it a long MFC, since the related commit 867c27c23a5c made a significant semantics change and, as such, has a long MFC. MFC after: 3 months --- sys/fs/nfsclient/nfs_clbio.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c index c3339617acce..06b51c050d34 100644 --- a/sys/fs/nfsclient/nfs_clbio.c +++ b/sys/fs/nfsclient/nfs_clbio.c @@ -1001,12 +1001,24 @@ ncl_write(struct vop_write_args *ap) if (uio->uio_resid == 0) return (0); + /* + * If the file in not mmap()'d, do IO_APPEND writing via a + * synchronous direct write. This can result in a significant + * performance improvement. + * If the file is mmap()'d, this cannot be done, since there + * is no way to maintain consistency between the file on the + * NFS server and the file's mmap()'d pages. + */ + NFSLOCKNODE(np); if (vp->v_type == VREG && ((newnfs_directio_enable && (ioflag & - IO_DIRECT)) || (ioflag & IO_APPEND))) { + IO_DIRECT)) || ((ioflag & IO_APPEND) && + (vp->v_object == NULL || !vm_object_is_active(vp->v_object))))) { + NFSUNLOCKNODE(np); if ((ioflag & IO_APPEND) != 0) ioflag |= IO_SYNC; return nfs_directio_write(vp, uio, cred, ioflag); } + NFSUNLOCKNODE(np); /* * Maybe this should be above the vnode op call, but so long as