Date: Wed, 29 Jul 2026 05:20:41 +0000 From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: fb4d7bd4b767 - main - vfs_busy(): add MBF_PCATCH flag to allow interrupting the sleep Message-ID: <6a698da9.329c0.29ae5aab@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=fb4d7bd4b7676963f9f37ff47f315f8c3652538b commit fb4d7bd4b7676963f9f37ff47f315f8c3652538b Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2026-07-27 13:40:23 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2026-07-29 05:20:07 +0000 vfs_busy(): add MBF_PCATCH flag to allow interrupting the sleep Reviewed by: jah, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D58477 --- sys/kern/vfs_subr.c | 17 ++++++++++++++++- sys/sys/mount.h | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 64c11660e211..8d6793ad9573 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -879,6 +879,7 @@ int vfs_busy(struct mount *mp, int flags) { struct mount_pcpu *mpcpu; + int error; MPASS((flags & ~MBF_MASK) == 0); CTR3(KTR_VFS, "%s: mp %p with flags %d", __func__, mp, flags); @@ -923,10 +924,24 @@ vfs_busy(struct mount *mp, int flags) if (flags & MBF_MNTLSTLOCK) mtx_unlock(&mountlist_mtx); mp->mnt_kern_flag |= MNTK_MWAIT; - msleep(mp, MNT_MTX(mp), PVFS | PDROP, "vfs_busy", 0); + error = msleep(mp, MNT_MTX(mp), ((flags & MBF_PCATCH) != 0 ? + PCATCH : 0) | PVFS | PDROP, "vfs_busy", 0); if (flags & MBF_MNTLSTLOCK) mtx_lock(&mountlist_mtx); MNT_ILOCK(mp); + if (error != 0) { + MNT_REL(mp); + + /* + * Clearing MNTK_MWAIT might cause spurious + * wakeups, but better clear our flag there + * then leak it. + */ + mp->mnt_kern_flag &= ~MNTK_MWAIT; + wakeup(mp); + MNT_IUNLOCK(mp); + return (error); + } } if (flags & MBF_MNTLSTLOCK) mtx_unlock(&mountlist_mtx); diff --git a/sys/sys/mount.h b/sys/sys/mount.h index b8b65a81369f..bc14a59da716 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -768,7 +768,8 @@ struct uio; */ #define MBF_NOWAIT 0x01 #define MBF_MNTLSTLOCK 0x02 -#define MBF_MASK (MBF_NOWAIT | MBF_MNTLSTLOCK) +#define MBF_PCATCH 0x04 +#define MBF_MASK (MBF_NOWAIT | MBF_MNTLSTLOCK | MBF_PCATCH) #ifdef MALLOC_DECLARE MALLOC_DECLARE(M_MOUNT);home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a698da9.329c0.29ae5aab>
