Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157562198
D56611.id177549.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D56611.id177549.diff
View Options
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -5737,7 +5737,7 @@
prev_mp = NULL;
for (;;) {
- if (!vfs_op_thread_enter_crit(mp, mpcpu)) {
+ if (!vfs_op_thread_enter_crit(mp, &mpcpu)) {
if (prev_mp != NULL)
vfs_op_thread_exit_crit(prev_mp, prev_mpcpu);
return (cache_fpl_partial(fpl));
@@ -5792,7 +5792,7 @@
return (0);
}
- if (!vfs_op_thread_enter_crit(mp, mpcpu)) {
+ if (!vfs_op_thread_enter_crit(mp, &mpcpu)) {
return (cache_fpl_partial(fpl));
}
if (!vn_seqc_consistent(vp, vp_seqc)) {
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -500,7 +500,7 @@
if (__predict_false(mp == NULL)) {
return (mp);
}
- if (vfs_op_thread_enter(mp, mpcpu)) {
+ if (vfs_op_thread_enter(mp, &mpcpu)) {
if (__predict_true(mp == vp->v_mount)) {
vfs_mp_count_add_pcpu(mpcpu, ref, 1);
vfs_op_thread_exit(mp, mpcpu);
@@ -527,7 +527,7 @@
struct mount_pcpu *mpcpu;
CTR2(KTR_VFS, "%s: mp %p", __func__, mp);
- if (vfs_op_thread_enter(mp, mpcpu)) {
+ if (vfs_op_thread_enter(mp, &mpcpu)) {
vfs_mp_count_add_pcpu(mpcpu, ref, 1);
vfs_op_thread_exit(mp, mpcpu);
return;
@@ -645,7 +645,7 @@
struct mount_pcpu *mpcpu;
CTR2(KTR_VFS, "%s: mp %p", __func__, mp);
- if (vfs_op_thread_enter(mp, mpcpu)) {
+ if (vfs_op_thread_enter(mp, &mpcpu)) {
vfs_mp_count_sub_pcpu(mpcpu, ref, 1);
vfs_op_thread_exit(mp, mpcpu);
return;
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
@@ -876,7 +876,7 @@
MPASS((flags & ~MBF_MASK) == 0);
CTR3(KTR_VFS, "%s: mp %p with flags %d", __func__, mp, flags);
- if (vfs_op_thread_enter(mp, mpcpu)) {
+ if (vfs_op_thread_enter(mp, &mpcpu)) {
MPASS((mp->mnt_kern_flag & MNTK_DRAINING) == 0);
MPASS((mp->mnt_kern_flag & MNTK_UNMOUNT) == 0);
MPASS((mp->mnt_kern_flag & MNTK_REFEXPIRE) == 0);
@@ -939,7 +939,7 @@
CTR2(KTR_VFS, "%s: mp %p", __func__, mp);
- if (vfs_op_thread_enter(mp, mpcpu)) {
+ if (vfs_op_thread_enter(mp, &mpcpu)) {
MPASS((mp->mnt_kern_flag & MNTK_DRAINING) == 0);
vfs_mp_count_sub_pcpu(mpcpu, lockref, 1);
vfs_mp_count_sub_pcpu(mpcpu, ref, 1);
@@ -6985,7 +6985,7 @@
struct vnode *vp;
int error;
- if (!vfs_op_thread_enter(mp, mpcpu))
+ if (!vfs_op_thread_enter(mp, &mpcpu))
return (vfs_cache_root_fallback(mp, flags, vpp));
vp = atomic_load_ptr(&mp->mnt_rootvnode);
if (vp == NULL || VN_IS_DOOMED(vp)) {
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -2083,7 +2083,7 @@
struct mount_pcpu *mpcpu;
int error, mflags;
- if ((flags & V_XSLEEP) == 0 && vfs_op_thread_enter(mp, mpcpu)) {
+ if ((flags & V_XSLEEP) == 0 && vfs_op_thread_enter(mp, &mpcpu)) {
MPASS((mp->mnt_kern_flag & MNTK_SUSPEND) == 0);
vfs_mp_count_add_pcpu(mpcpu, writeopcount, 1);
vfs_op_thread_exit(mp, mpcpu);
@@ -2252,7 +2252,7 @@
if (mp == NULL)
return;
- if (vfs_op_thread_enter(mp, mpcpu)) {
+ if (vfs_op_thread_enter(mp, &mpcpu)) {
vfs_mp_count_sub_pcpu(mpcpu, writeopcount, 1);
vfs_mp_count_sub_pcpu(mpcpu, ref, 1);
vfs_op_thread_exit(mp, mpcpu);
diff --git a/sys/sys/mount.h b/sys/sys/mount.h
--- a/sys/sys/mount.h
+++ b/sys/sys/mount.h
@@ -36,8 +36,10 @@
#include <sys/ucred.h>
#include <sys/queue.h>
#ifdef _KERNEL
+#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/lockmgr.h>
+#include <sys/proc.h>
#include <sys/tslog.h>
#include <sys/_mutex.h>
#include <sys/_sx.h>
@@ -1137,47 +1139,64 @@
*/
#define vfs_mount_pcpu(mp) zpcpu_get(mp->mnt_pcpu)
#define vfs_mount_pcpu_remote(mp, cpu) zpcpu_get_cpu(mp->mnt_pcpu, cpu)
+static void vfs_op_thread_exit_crit(struct mount *mp, struct mount_pcpu *mpcpu);
-#define vfs_op_thread_entered(mp) ({ \
- MPASS(curthread->td_critnest > 0); \
- struct mount_pcpu *_mpcpu = vfs_mount_pcpu(mp); \
- _mpcpu->mntp_thread_in_ops == 1; \
-})
-
-#define vfs_op_thread_enter_crit(mp, _mpcpu) ({ \
- bool _retval_crit = true; \
- MPASS(curthread->td_critnest > 0); \
- _mpcpu = vfs_mount_pcpu(mp); \
- MPASS(mpcpu->mntp_thread_in_ops == 0); \
- _mpcpu->mntp_thread_in_ops = 1; \
- atomic_interrupt_fence(); \
- if (__predict_false(mp->mnt_vfs_ops > 0)) { \
- vfs_op_thread_exit_crit(mp, _mpcpu); \
- _retval_crit = false; \
- } \
- _retval_crit; \
-})
-
-#define vfs_op_thread_enter(mp, _mpcpu) ({ \
- bool _retval; \
- critical_enter(); \
- _retval = vfs_op_thread_enter_crit(mp, _mpcpu); \
- if (__predict_false(!_retval)) \
- critical_exit(); \
- _retval; \
-})
-
-#define vfs_op_thread_exit_crit(mp, _mpcpu) do { \
- MPASS(_mpcpu == vfs_mount_pcpu(mp)); \
- MPASS(_mpcpu->mntp_thread_in_ops == 1); \
- atomic_interrupt_fence(); \
- _mpcpu->mntp_thread_in_ops = 0; \
-} while (0)
+static inline bool
+vfs_op_thread_entered(struct mount *mp)
+{
+ struct mount_pcpu *mpcpu = vfs_mount_pcpu(mp);
-#define vfs_op_thread_exit(mp, _mpcpu) do { \
- vfs_op_thread_exit_crit(mp, _mpcpu); \
- critical_exit(); \
-} while (0)
+ MPASS(curthread->td_critnest > 0);
+ return (mpcpu->mntp_thread_in_ops == 1);
+}
+
+static inline bool
+vfs_op_thread_enter_crit(struct mount *mp, struct mount_pcpu **mpcpup)
+{
+ struct mount_pcpu *mpcpu;
+ bool retval_crit = true;
+
+ MPASS(curthread->td_critnest > 0);
+ mpcpu = vfs_mount_pcpu(mp);
+ MPASS(mpcpu->mntp_thread_in_ops == 0);
+ mpcpu->mntp_thread_in_ops = 1;
+ atomic_interrupt_fence();
+ if (__predict_false(mp->mnt_vfs_ops > 0)) {
+ vfs_op_thread_exit_crit(mp, mpcpu);
+ retval_crit = false;
+ }
+ *mpcpup = mpcpu;
+ return (retval_crit);
+}
+
+static inline bool
+vfs_op_thread_enter(struct mount *mp, struct mount_pcpu **mpcpup)
+{
+ bool retval;
+
+ critical_enter();
+ retval = vfs_op_thread_enter_crit(mp, mpcpup);
+ if (__predict_false(!retval))
+ critical_exit();
+ return (retval);
+}
+
+static inline void
+vfs_op_thread_exit_crit(struct mount *mp, struct mount_pcpu *mpcpu)
+{
+ MPASS(mpcpu == vfs_mount_pcpu(mp));
+ MPASS(mpcpu->mntp_thread_in_ops == 1);
+
+ atomic_interrupt_fence();
+ mpcpu->mntp_thread_in_ops = 0;
+}
+
+static inline void
+vfs_op_thread_exit(struct mount *mp, struct mount_pcpu *mpcpu)
+{
+ vfs_op_thread_exit_crit(mp, mpcpu);
+ critical_exit();
+}
#define vfs_mp_count_add_pcpu(_mpcpu, count, val) do { \
MPASS(_mpcpu->mntp_thread_in_ops == 1); \
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, May 23, 8:52 PM (18 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33454144
Default Alt Text
D56611.id177549.diff (6 KB)
Attached To
Mode
D56611: Convert bunch of macros from sys/mount.h into static inlines
Attached
Detach File
Event Timeline
Log In to Comment