git: dd16a5f53b0b - main - lockf: Do not block in vfs_busy()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 24 Sep 2026 16:20:35 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=dd16a5f53b0b2e967d20d2900f18fc320997679b
commit dd16a5f53b0b2e967d20d2900f18fc320997679b
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-09-24 16:14:34 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-09-24 16:20:25 +0000
lockf: Do not block in vfs_busy()
A race is possible otherwise: vfs_busy() may return after an unmounted
filesystem has been removed from the global mount list. That is,
vfs_busy() will block until vfs_mount_destroy() sets MNTK_REFEXPIRE, and
at that point the mountpoint has been removed from the mountlist, so
TAILQ_FOREACH can return an invalid value.
Simply do not block if the mountpoint is being unmounted.
Reviewed by: kib
Fixes: eca39864f702 ("Add sysctl KERN_LOCKF")
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D59982
---
sys/kern/kern_lockf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys/kern/kern_lockf.c b/sys/kern/kern_lockf.c
index a318c26484b4..2cb02b21cd78 100644
--- a/sys/kern/kern_lockf.c
+++ b/sys/kern/kern_lockf.c
@@ -2558,7 +2558,7 @@ sysctl_kern_lockf_run(struct sbuf *sb)
error = 0;
mtx_lock(&mountlist_mtx);
TAILQ_FOREACH(mp, &mountlist, mnt_list) {
- error = vfs_busy(mp, MBF_MNTLSTLOCK);
+ error = vfs_busy(mp, MBF_MNTLSTLOCK | MBF_NOWAIT);
if (error != 0)
continue;
error = mp->mnt_op->vfs_report_lockf(mp, sb);