git: 4adb1ced83f4 - stable/12 - nfscl: Fix must_commit handling for mirrored pNFS mounts

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Sun, 26 Dec 2021 02:40:19 UTC
The branch stable/12 has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=4adb1ced83f4685c9c287aebebed1bf75f4ac20a

commit 4adb1ced83f4685c9c287aebebed1bf75f4ac20a
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2021-12-12 23:40:30 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2021-12-26 02:36:55 +0000

    nfscl: Fix must_commit handling for mirrored pNFS mounts
    
    For pNFS mounts to mirrored Flexible File layout pNFS servers,
    the "must_commit" component in the nfsclwritedsdorpc
    structure must be checked and the "must_commit" argument passed
    into nfscl_doiods() must be updated.  Technically, only writes to
    the DS with a writeverf change must be redone, but since this
    occurrence will be rare, the must_commit argument to nfscl_doiosd()
    is set to 1, so all writes to all DSs will be redone.
    
    This bug would affect few, since use of mirrored pNFS servers
    is rare and "writeverf" rarely changes. Normally "writeverf"
    only changes when a NFS server reboots.
    
    (cherry picked from commit 24947b701d07634434b3208b0a0c970235f9d16e)
---
 sys/fs/nfsclient/nfs_clrpcops.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c
index d30ca62c673e..a11a1474207c 100644
--- a/sys/fs/nfsclient/nfs_clrpcops.c
+++ b/sys/fs/nfsclient/nfs_clrpcops.c
@@ -5833,6 +5833,10 @@ nfscl_doiods(vnode_t vp, struct uio *uiop, int *iomode, int *must_commit,
 					    timo);
 				if (error == 0 && tdrpc->err != 0)
 					error = tdrpc->err;
+				if (rwaccess != NFSV4OPEN_ACCESSREAD &&
+				    docommit == 0 && *must_commit == 0 &&
+				    tdrpc->must_commit == 1)
+					*must_commit = 1;
 			}
 			free(drpc, M_TEMP);
 			if (error == 0) {
@@ -6574,8 +6578,8 @@ nfsio_writedsmir(vnode_t vp, int *iomode, int *must_commit,
 		NFSCL_DEBUG(4, "nfsio_writedsmir: nfs_pnfsio=%d\n", ret);
 	}
 	if (ret != 0)
-		error = nfsrpc_writedsmir(vp, iomode, must_commit, stateidp,
-		    dsp, off, len, fhp, m, vers, minorvers, cred, p);
+		error = nfsrpc_writedsmir(vp, iomode, &drpc->must_commit,
+		    stateidp, dsp, off, len, fhp, m, vers, minorvers, cred, p);
 	NFSCL_DEBUG(4, "nfsio_writedsmir: error=%d\n", error);
 	return (error);
 }