From e81e71b0e9cbb5515ffb31bf80088fd7b20e7994 Mon Sep 17 00:00:00 2001 From: "Jason A. Harmening" Date: Sat, 7 Aug 2021 22:31:02 -0700 Subject: [PATCH] Use interruptible wait for blocking recursive unmounts Now that we allow recursive unmount attempts to be abandoned upon exceeding the retry limit, we should avoid leaving an unkillable thread when a synchronous unmount request was issued against the base filesystem. Reviewed by: kib (earlier revision), mkusick Differential Revision: https://reviews.freebsd.org/D31450 --- sys/kern/vfs_mount.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 0fb5694ebed..166d7336eaf 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -2084,10 +2084,15 @@ dounmount(struct mount *mp, uint64_t flags, struct thread *td) * just re-enqueue on the end of the taskqueue. */ if ((flags & MNT_DEFERRED) == 0) { - while (!TAILQ_EMPTY(&mp->mnt_uppers)) { + while (error == 0 && !TAILQ_EMPTY(&mp->mnt_uppers)) { mp->mnt_kern_flag |= MNTK_TASKQUEUE_WAITER; - msleep(&mp->mnt_taskqueue_link, MNT_MTX(mp), 0, - "umntqw", 0); + error = msleep(&mp->mnt_taskqueue_link, + MNT_MTX(mp), PCATCH, "umntqw", 0); + } + if (error != 0) { + MNT_REL(mp); + MNT_IUNLOCK(mp); + return (error); } } else if (!TAILQ_EMPTY(&mp->mnt_uppers)) { MNT_IUNLOCK(mp);