git: 6b67753488cb - main - nfscl: Fix forced dismount from looping on commit

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Wed, 03 Nov 2021 21:29:33 UTC
The branch main has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=6b67753488cb506f05694c5f6d2e74cf53497c54

commit 6b67753488cb506f05694c5f6d2e74cf53497c54
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2021-11-03 21:25:44 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2021-11-03 21:25:44 +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.
    
    MFC after:      2 weeks
---
 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 250d01d88948..73f559ad82f8 100644
--- a/sys/fs/nfsclient/nfs_clbio.c
+++ b/sys/fs/nfsclient/nfs_clbio.c
@@ -1738,7 +1738,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 1685edf5b2de..abccf82e3ff0 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -3067,7 +3067,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
 				 */