git: 00e9bc2d937f - stable/12 - nfscl: Fix forced dismount from looping on commit

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Wed, 17 Nov 2021 01:36:54 UTC
The branch stable/12 has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=00e9bc2d937fd8de6638c4a5669e78f04cd94110

commit 00e9bc2d937fd8de6638c4a5669e78f04cd94110
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2021-11-03 21:25:44 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2021-11-17 01:33:19 +0000

    nfscl: Fix forced dismount from looping on commit
    
    When a forced dismount is in progress, it is possible to
    end up looping, retrying commits that fail.
    This patch fixes the problem by pretending
    that commits succeeded when a forced dismount is in prgress.
    
    (cherry picked from commit 6b67753488cb506f05694c5f6d2e74cf53497c54)
---
 sys/fs/nfsclient/nfs_clbio.c   | 2 +-
 sys/fs/nfsclient/nfs_clvnops.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c
index c61cb1db9b95..52eb879caafb 100644
--- a/sys/fs/nfsclient/nfs_clbio.c
+++ b/sys/fs/nfsclient/nfs_clbio.c
@@ -1726,7 +1726,7 @@ ncl_doio(struct vnode *vp, struct buf *bp, struct ucred *cr, struct thread *td,
 		    off = ((u_quad_t)bp->b_blkno) * DEV_BSIZE + bp->b_dirtyoff;
 		    retv = ncl_commit(vp, off, bp->b_dirtyend-bp->b_dirtyoff,
 			bp->b_wcred, td);
-		    if (retv == 0) {
+		    if (NFSCL_FORCEDISM(vp->v_mount) || retv == 0) {
 			    bp->b_dirtyoff = bp->b_dirtyend = 0;
 			    bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK);
 			    bp->b_resid = 0;
diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index 17859a16424b..ffa8e41ec578 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -2934,7 +2934,7 @@ again:
 		for (i = 0; i < bvecpos; i++) {
 			bp = bvec[i];
 			bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK);
-			if (retv) {
+			if (!NFSCL_FORCEDISM(vp->v_mount) && retv) {
 				/*
 				 * Error, leave B_DELWRI intact
 				 */