git: d9259de0a623 - stable/14 - softdep_mount: report failure of the softdepflush thread creation

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 22 Sep 2024 09:36:52 UTC
The branch stable/14 has been updated by kib:

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

commit d9259de0a6232b1a28787add531cc6627718768d
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-09-15 08:06:31 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-09-21 21:19:50 +0000

    softdep_mount: report failure of the softdepflush thread creation
    
    PR:     281511
    
    (cherry picked from commit 4b273a7fb9e6d9a006c5ac7cbd27f5d006569edb)
---
 sys/ufs/ffs/ffs_softdep.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c
index 90f37c2c1ac3..3729d67d1eb2 100644
--- a/sys/ufs/ffs/ffs_softdep.c
+++ b/sys/ufs/ffs/ffs_softdep.c
@@ -2646,10 +2646,18 @@ softdep_mount(struct vnode *devvp,
 	ACQUIRE_LOCK(ump);
 	ump->softdep_flags |= FLUSH_STARTING;
 	FREE_LOCK(ump);
-	kproc_kthread_add(&softdep_flush, mp, &bufdaemonproc,
+	error = kproc_kthread_add(&softdep_flush, mp, &bufdaemonproc,
 	    &ump->softdep_flushtd, 0, 0, "softdepflush", "%s worker",
 	    mp->mnt_stat.f_mntonname);
 	ACQUIRE_LOCK(ump);
+	if (error != 0) {
+		printf("%s: failed to start softdepflush thread: %d\n",
+		    mp->mnt_stat.f_mntonname, error);
+		ump->softdep_flags &= ~FLUSH_STARTING;
+		FREE_LOCK(ump);
+		softdep_unmount(mp);
+		return (error);
+	}
 	while ((ump->softdep_flags & FLUSH_STARTING) != 0) {
 		msleep(&ump->softdep_flushtd, LOCK_PTR(ump), PVM, "sdstart",
 		    hz / 2);