Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177580343
D21574.1794792941.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D21574.1794792941.diff
View Options
Index: sys/kern/vfs_subr.c
===================================================================
--- sys/kern/vfs_subr.c
+++ sys/kern/vfs_subr.c
@@ -73,6 +73,7 @@
#include <sys/priv.h>
#include <sys/reboot.h>
#include <sys/refcount.h>
+#include <sys/rmlock.h>
#include <sys/rwlock.h>
#include <sys/sched.h>
#include <sys/sleepqueue.h>
@@ -637,10 +638,23 @@
int
vfs_busy(struct mount *mp, int flags)
{
+ struct rm_priotracker tracker;
MPASS((flags & ~MBF_MASK) == 0);
CTR3(KTR_VFS, "%s: mp %p with flags %d", __func__, mp, flags);
+ if (vfs_op_thread_enter(mp, &tracker)) {
+ MPASS((mp->mnt_kern_flag & MNTK_DRAINING) == 0);
+ MPASS((mp->mnt_kern_flag & MNTK_UNMOUNT) == 0);
+ MPASS((mp->mnt_kern_flag & MNTK_REFEXPIRE) == 0);
+ MNT_REF_FASTPATH(mp);
+ atomic_add_int(&mp->mnt_lockref, 1);
+ if (flags & MBF_MNTLSTLOCK)
+ mtx_unlock(&mountlist_mtx);
+ vfs_op_thread_exit(mp, &tracker);
+ return (0);
+ }
+
MNT_ILOCK(mp);
MNT_REF(mp);
/*
@@ -673,7 +687,7 @@
}
if (flags & MBF_MNTLSTLOCK)
mtx_unlock(&mountlist_mtx);
- mp->mnt_lockref++;
+ atomic_add_int(&mp->mnt_lockref, 1);
MNT_IUNLOCK(mp);
return (0);
}
@@ -684,13 +698,25 @@
void
vfs_unbusy(struct mount *mp)
{
+ struct rm_priotracker tracker;
+ int c;
CTR2(KTR_VFS, "%s: mp %p", __func__, mp);
+
+ if (vfs_op_thread_enter(mp, &tracker)) {
+ MPASS((mp->mnt_kern_flag & MNTK_DRAINING) == 0);
+ c = atomic_fetchadd_int(&mp->mnt_lockref, -1) - 1;
+ KASSERT(c >= 0, ("%s: negative mnt_lockref %d\n", __func__, c));
+ MNT_REL_FASTPATH(mp);
+ vfs_op_thread_exit(mp, &tracker);
+ return;
+ }
+
MNT_ILOCK(mp);
MNT_REL(mp);
- KASSERT(mp->mnt_lockref > 0, ("negative mnt_lockref"));
- mp->mnt_lockref--;
- if (mp->mnt_lockref == 0 && (mp->mnt_kern_flag & MNTK_DRAINING) != 0) {
+ c = atomic_fetchadd_int(&mp->mnt_lockref, -1) - 1;
+ KASSERT(c >= 0, ("%s: negative mnt_lockref %d\n", __func__, c));
+ if (c == 0 && (mp->mnt_kern_flag & MNTK_DRAINING) != 0) {
MPASS(mp->mnt_kern_flag & MNTK_UNMOUNT);
CTR1(KTR_VFS, "%s: waking up waiters", __func__);
mp->mnt_kern_flag &= ~MNTK_DRAINING;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 16, 1:35 AM (11 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41754291
Default Alt Text
D21574.1794792941.diff (2 KB)
Attached To
Mode
D21574: vfs: manage mnt_lockref with atomics
Attached
Detach File
Event Timeline