Page MenuHomeFreeBSD

D58477.id183019.diff
No OneTemporary

D58477.id183019.diff

diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -879,6 +879,7 @@
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 @@
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
--- a/sys/sys/mount.h
+++ b/sys/sys/mount.h
@@ -768,7 +768,8 @@
*/
#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);

File Metadata

Mime Type
text/plain
Expires
Wed, Sep 9, 7:23 PM (15 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38606899
Default Alt Text
D58477.id183019.diff (1 KB)

Event Timeline