git: 468043bbaeb9 - stable/13 - nfscl: Fix must_commit handling for mirrored pNFS mounts

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

URL: https://cgit.FreeBSD.org/src/commit/?id=468043bbaeb910657536d7c9d146818c00eea193

commit 468043bbaeb910657536d7c9d146818c00eea193
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:22:20 +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 2e1d3e86c1d2..72e3b74aa31e 100644
--- a/sys/fs/nfsclient/nfs_clrpcops.c
+++ b/sys/fs/nfsclient/nfs_clrpcops.c
@@ -6007,6 +6007,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) {
@@ -6755,8 +6759,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);
 }