git: 3f2ac12e658c - stable/13 - nfscl: Partially revert commit 867c27c23a5c

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Thu, 09 Jun 2022 04:16:12 UTC
The branch stable/13 has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=3f2ac12e658c3e9b36fcd501e225cb3261f9c388

commit 3f2ac12e658c3e9b36fcd501e225cb3261f9c388
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2021-12-16 22:30:37 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2022-06-09 04:15:32 +0000

    nfscl: Partially revert commit 867c27c23a5c
    
    Commit 867c27c23a5c enabled the n_directio_opens code
    in open/close, which sets/clears NNONCACHE, for
    IO_APPEND. This code should not be enabled unless
    newnfs_directio_enable is non-zero.
    
    This patch reverts that part of commit 867c27c23a5c.
    
    A future patch that fixes the case where the
    file that is being written IO_APPEND is mmap()'d.
    
    (cherry picked from commit 150da1e3cd51e552f7d6bc159b387e540c5a3733)
---
 sys/fs/nfsclient/nfs_clvnops.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index 538f029a8bfd..38b637c5c062 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -707,8 +707,8 @@ nfs_open(struct vop_open_args *ap)
 	/*
 	 * If the object has >= 1 O_DIRECT active opens, we disable caching.
 	 */
-	if (vp->v_type == VREG && ((newnfs_directio_enable && (fmode &
-	    O_DIRECT)) || (fmode & O_APPEND))) {
+	if (newnfs_directio_enable && (fmode & O_DIRECT) &&
+	    (vp->v_type == VREG)) {
 		if (np->n_directio_opens == 0) {
 			NFSUNLOCKNODE(np);
 			if (VOP_ISLOCKED(vp) != LK_EXCLUSIVE) {
@@ -965,11 +965,11 @@ nfs_close(struct vop_close_args *ap)
 			error = nfscl_maperr(ap->a_td, error, (uid_t)0,
 			    (gid_t)0);
 	}
-	if (vp->v_type == VREG && ((newnfs_directio_enable && (fmode &
-	    O_DIRECT)) || (fmode & O_APPEND))) {
+	if (newnfs_directio_enable)
 		KASSERT((np->n_directio_asyncwr == 0),
 			("nfs_close: dirty unflushed (%d) directio buffers\n",
 			 np->n_directio_asyncwr));
+	if (newnfs_directio_enable && (fmode & O_DIRECT) && (vp->v_type == VREG)) {
 		NFSLOCKNODE(np);
 		KASSERT((np->n_directio_opens > 0), 
 			("nfs_close: unexpectedly value (0) of n_directio_opens\n"));