git: e45f10165847 - stable/13 - msdosfs_integrity_error(): plug possible busy leak

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Thu, 25 Jan 2024 04:32:12 UTC
The branch stable/13 has been updated by kib:

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

commit e45f10165847baf419dbec40d0f10c0b2864442f
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-01-18 15:35:56 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-01-24 13:04:38 +0000

    msdosfs_integrity_error(): plug possible busy leak
    
    (cherry picked from commit 13ccb04589e2c5c840e19b407a59e44cb70ac28e)
---
 sys/fs/msdosfs/msdosfs_vfsops.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c
index 73082976ec46..fe367122b3e3 100644
--- a/sys/fs/msdosfs/msdosfs_vfsops.c
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c
@@ -1008,7 +1008,9 @@ msdosfs_remount_ro(void *arg, int pending)
 	}
 	MSDOSFS_UNLOCK_MP(pmp);
 
-	vfs_unbusy(pmp->pm_mountp);
+	do {
+		vfs_unbusy(pmp->pm_mountp);
+	} while (--pending >= 0);
 }
 
 void
@@ -1017,11 +1019,19 @@ msdosfs_integrity_error(struct msdosfsmount *pmp)
 	int error;
 
 	error = vfs_busy(pmp->pm_mountp, MBF_NOWAIT);
-	if (error == 0)
-		taskqueue_enqueue(taskqueue_thread, &pmp->pm_rw2ro_task);
-	else
+	if (error == 0) {
+		error = taskqueue_enqueue(taskqueue_thread,
+		    &pmp->pm_rw2ro_task);
+		if (error != 0) {
+			printf("%s: integrity error scheduling failed, "
+			    "error %d\n",
+			    pmp->pm_mountp->mnt_stat.f_mntfromname, error);
+			vfs_unbusy(pmp->pm_mountp);
+		}
+	} else {
 		printf("%s: integrity error busying failed, error %d\n",
 		    pmp->pm_mountp->mnt_stat.f_mntfromname, error);
+	}
 }
 
 static int