vfs: convert vfs_op_thread_* macros to static inlines
Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D56611
This commit is contained in:
@@ -5737,7 +5737,7 @@ cache_fplookup_climb_mount(struct cache_fpl *fpl)
|
||||
|
||||
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 @@ cache_fplookup_cross_mount(struct cache_fpl *fpl)
|
||||
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)) {
|
||||
|
||||
@@ -500,7 +500,7 @@ vfs_ref_from_vp(struct vnode *vp)
|
||||
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 @@ vfs_ref(struct mount *mp)
|
||||
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 @@ vfs_rel(struct mount *mp)
|
||||
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;
|
||||
|
||||
+3
-3
@@ -879,7 +879,7 @@ vfs_busy(struct mount *mp, int flags)
|
||||
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);
|
||||
@@ -942,7 +942,7 @@ vfs_unbusy(struct mount *mp)
|
||||
|
||||
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);
|
||||
@@ -6988,7 +6988,7 @@ vfs_cache_root(struct mount *mp, int flags, struct vnode **vpp)
|
||||
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)) {
|
||||
|
||||
@@ -2083,7 +2083,7 @@ vn_start_write_refed(struct mount *mp, int flags)
|
||||
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 @@ vn_finished_write(struct mount *mp)
|
||||
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);
|
||||
|
||||
+55
-36
@@ -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>
|
||||
@@ -1138,47 +1140,64 @@ void resume_all_fs(void);
|
||||
*/
|
||||
#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; \
|
||||
})
|
||||
static inline bool
|
||||
vfs_op_thread_entered(struct mount *mp)
|
||||
{
|
||||
struct mount_pcpu *mpcpu = vfs_mount_pcpu(mp);
|
||||
|
||||
#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; \
|
||||
})
|
||||
MPASS(curthread->td_critnest > 0);
|
||||
return (mpcpu->mntp_thread_in_ops == 1);
|
||||
}
|
||||
|
||||
#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; \
|
||||
})
|
||||
static inline bool
|
||||
vfs_op_thread_enter_crit(struct mount *mp, struct mount_pcpu **mpcpup)
|
||||
{
|
||||
struct mount_pcpu *mpcpu;
|
||||
bool retval_crit = true;
|
||||
|
||||
#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)
|
||||
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);
|
||||
}
|
||||
|
||||
#define vfs_op_thread_exit(mp, _mpcpu) do { \
|
||||
vfs_op_thread_exit_crit(mp, _mpcpu); \
|
||||
critical_exit(); \
|
||||
} while (0)
|
||||
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); \
|
||||
|
||||
Reference in New Issue
Block a user