git: 24947b701d07 - main - nfscl: Fix must_commit handling for mirrored pNFS mounts

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Sun, 12 Dec 2021 23:44:10 UTC
The branch main has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=24947b701d07634434b3208b0a0c970235f9d16e

commit 24947b701d07634434b3208b0a0c970235f9d16e
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2021-12-12 23:40:30 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2021-12-12 23:40:30 +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.
    
    MFC after:      2 weeks
---
 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 56ce2a5e2077..e7558b85a46f 100644
--- a/sys/fs/nfsclient/nfs_clrpcops.c
+++ b/sys/fs/nfsclient/nfs_clrpcops.c
@@ -6253,6 +6253,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) {
@@ -7001,8 +7005,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);
 }