Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F165312791
D56611.id176310.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
13 KB
Referenced Files
None
Subscribers
None
D56611.id176310.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
@@ -879,7 +879,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);
@@ -942,7 +942,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);
@@ -6988,7 +6988,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);
@@ -4500,3 +4500,12 @@
return (3);
return (kcmp_cmp((uintptr_t)fp1->f_vnode, (uintptr_t)fp2->f_vnode));
}
+
+void
+vn_knote(struct vnode *vp, int hint, int flags)
+{
+ if (!VN_KNLIST_EMPTY(vp)) {
+ KNOTE(&vp->v_pollinfo->vpi_selinfo.si_note, hint,
+ flags | KNF_NOKQLOCK);
+ }
+}
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>
@@ -851,114 +853,128 @@
vfs_statfs_t __vfs_statfs;
-#define VFS_MOUNT(MP) ({ \
- int _rc; \
- \
- TSRAW(curthread, TS_ENTER, "VFS_MOUNT", (MP)->mnt_vfc->vfc_name);\
- _rc = (*(MP)->mnt_op->vfs_mount)(MP); \
- TSRAW(curthread, TS_EXIT, "VFS_MOUNT", (MP)->mnt_vfc->vfc_name);\
- _rc; })
+static inline int
+VFS_MOUNT(struct mount *mp)
+{
+ int rc; \
-#define VFS_UNMOUNT(MP, FORCE) ({ \
- int _rc; \
- \
- _rc = (*(MP)->mnt_op->vfs_unmount)(MP, FORCE); \
- _rc; })
+ TSRAW(curthread, TS_ENTER, "VFS_MOUNT", mp->mnt_vfc->vfc_name);
+ rc = mp->mnt_op->vfs_mount(mp);
+ TSRAW(curthread, TS_EXIT, "VFS_MOUNT", mp->mnt_vfc->vfc_name);
+ return (rc);
+}
-#define VFS_ROOT(MP, FLAGS, VPP) ({ \
- int _rc; \
- \
- _rc = (*(MP)->mnt_op->vfs_root)(MP, FLAGS, VPP); \
- _rc; })
+static inline int
+VFS_UNMOUNT(struct mount *mp, int force)
+{
+ return (mp->mnt_op->vfs_unmount(mp, force));
+}
-#define VFS_CACHEDROOT(MP, FLAGS, VPP) ({ \
- int _rc; \
- \
- _rc = (*(MP)->mnt_op->vfs_cachedroot)(MP, FLAGS, VPP); \
- _rc; })
+static inline int
+VFS_ROOT(struct mount *mp, int flags, struct vnode **vpp)
+{
+ return (mp->mnt_op->vfs_root(mp, flags, vpp));
+}
-#define VFS_QUOTACTL(MP, C, U, A, MP_BUSY) ({ \
- int _rc; \
- \
- _rc = (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, MP_BUSY); \
- _rc; })
+static inline int
+VFS_CACHEDROOT(struct mount *mp, int flags, struct vnode **vpp)
+{
+ return (mp->mnt_op->vfs_cachedroot(mp, flags, vpp));
+}
-#define VFS_STATFS(MP, SBP) ({ \
- int _rc; \
- \
- _rc = __vfs_statfs((MP), (SBP)); \
- _rc; })
+static inline int
+VFS_QUOTACTL(struct mount *mp, int cmds, uid_t uid, void *arg, bool *mp_busy)
+{
+ return (mp->mnt_op->vfs_quotactl(mp, cmds, uid, arg, mp_busy));
+}
-#define VFS_SYNC(MP, WAIT) ({ \
- int _rc; \
- \
- _rc = (*(MP)->mnt_op->vfs_sync)(MP, WAIT); \
- _rc; })
+static inline int
+VFS_STATFS(struct mount *mp, struct statfs *sbp)
+{
+ return (__vfs_statfs(mp, sbp));
+}
-#define VFS_VGET(MP, INO, FLAGS, VPP) ({ \
- int _rc; \
- \
- _rc = (*(MP)->mnt_op->vfs_vget)(MP, INO, FLAGS, VPP); \
- _rc; })
+static inline int
+VFS_SYNC(struct mount *mp, int waitfor)
+{
+ return (mp->mnt_op->vfs_sync(mp, waitfor));
+}
-#define VFS_FHTOVP(MP, FIDP, FLAGS, VPP) ({ \
- int _rc; \
- \
- _rc = (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, FLAGS, VPP); \
- _rc; })
+static inline int
+VFS_VGET(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
+{
+ return (mp->mnt_op->vfs_vget(mp, ino, flags, vpp));
+}
-#define VFS_CHECKEXP(MP, NAM, EXFLG, CRED, NUMSEC, SEC) ({ \
- int _rc; \
- \
- _rc = (*(MP)->mnt_op->vfs_checkexp)(MP, NAM, EXFLG, CRED, NUMSEC,\
- SEC); \
- _rc; })
+static inline int
+VFS_FHTOVP(struct mount *mp, struct fid *fidp, int flags, struct vnode **vpp)
+{
+ return (mp->mnt_op->vfs_fhtovp(mp, fidp, flags, vpp));
+}
-#define VFS_EXTATTRCTL(MP, C, FN, NS, N) ({ \
- int _rc; \
- \
- _rc = (*(MP)->mnt_op->vfs_extattrctl)(MP, C, FN, NS, N); \
- _rc; })
+static inline int
+VFS_CHECKEXP(struct mount *mp, struct sockaddr *nam, uint64_t *extflagsp,
+ struct ucred **credanonp, int *numsecflavors, int *secflavors)
+{
+ return (mp->mnt_op->vfs_checkexp(mp, nam, extflagsp, credanonp,
+ numsecflavors, secflavors));
+}
-#define VFS_SYSCTL(MP, OP, REQ) ({ \
- int _rc; \
- \
- _rc = (*(MP)->mnt_op->vfs_sysctl)(MP, OP, REQ); \
- _rc; })
+static inline int
+VFS_EXTATTRCTL(struct mount *mp, int cmd, struct vnode *filename_vp,
+ int attrnamespace, const char *attrname)
+{
+ return (mp->mnt_op->vfs_extattrctl(mp, cmd, filename_vp,
+ attrnamespace, attrname));
+}
-#define VFS_SUSP_CLEAN(MP) do { \
- if (*(MP)->mnt_op->vfs_susp_clean != NULL) { \
- (*(MP)->mnt_op->vfs_susp_clean)(MP); \
- } \
-} while (0)
+static inline int
+VFS_SYSCTL(struct mount *mp, fsctlop_t op, struct sysctl_req *req)
+{
+ return (mp->mnt_op->vfs_sysctl(mp, op, req));
+}
-#define VFS_RECLAIM_LOWERVP(MP, VP) do { \
- if (*(MP)->mnt_op->vfs_reclaim_lowervp != NULL) { \
- (*(MP)->mnt_op->vfs_reclaim_lowervp)((MP), (VP)); \
- } \
-} while (0)
+static inline void
+VFS_SUSP_CLEAN(struct mount *mp)
+{
+ if (mp->mnt_op->vfs_susp_clean != NULL)
+ mp->mnt_op->vfs_susp_clean(mp);
+}
-#define VFS_UNLINK_LOWERVP(MP, VP) do { \
- if (*(MP)->mnt_op->vfs_unlink_lowervp != NULL) { \
- (*(MP)->mnt_op->vfs_unlink_lowervp)((MP), (VP)); \
- } \
-} while (0)
+static inline void
+VFS_RECLAIM_LOWERVP(struct mount *mp, struct vnode *vp)
+{
+ if (mp->mnt_op->vfs_reclaim_lowervp != NULL)
+ mp->mnt_op->vfs_reclaim_lowervp(mp, vp);
+}
-#define VFS_PURGE(MP) do { \
- if (*(MP)->mnt_op->vfs_purge != NULL) { \
- (*(MP)->mnt_op->vfs_purge)(MP); \
- } \
-} while (0)
+static inline void
+VFS_UNLINK_LOWERVP(struct mount *mp, struct vnode *vp)
+{
+ if (mp->mnt_op->vfs_unlink_lowervp != NULL)
+ mp->mnt_op->vfs_unlink_lowervp(mp, vp);
+}
-#define VFS_KNOTE_LOCKED(vp, hint) do \
-{ \
- VN_KNOTE((vp), (hint), KNF_LISTLOCKED); \
-} while (0)
+static inline void
+VFS_PURGE(struct mount *mp)
+{
+ if (mp->mnt_op->vfs_purge != NULL)
+ mp->mnt_op->vfs_purge(mp);
+}
-#define VFS_KNOTE_UNLOCKED(vp, hint) do \
-{ \
- VN_KNOTE((vp), (hint), 0); \
-} while (0)
+void vn_knote(struct vnode *vp, int hint, int flags);
+
+static inline void
+VFS_KNOTE_LOCKED(struct vnode *vp, int hint)
+{
+ vn_knote(vp, hint, KNF_LISTLOCKED);
+}
+
+static inline void
+VFS_KNOTE_UNLOCKED(struct vnode *vp, int hint)
+{
+ vn_knote(vp, hint, 0);
+}
#include <sys/module.h>
@@ -1138,47 +1154,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; \
-})
+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); \
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -221,21 +221,15 @@
#define bo2vnode(bo) __containerof((bo), struct vnode, v_bufobj)
-/* XXX: These are temporary to avoid a source sweep at this time */
#define v_object v_bufobj.bo_object
/* We don't need to lock the knlist */
#define VN_KNLIST_EMPTY(vp) ((vp)->v_pollinfo == NULL || \
- KNLIST_EMPTY(&(vp)->v_pollinfo->vpi_selinfo.si_note))
+ KNLIST_EMPTY(&(vp)->v_pollinfo->vpi_selinfo.si_note))
-#define VN_KNOTE(vp, b, a) \
- do { \
- if (!VN_KNLIST_EMPTY(vp)) \
- KNOTE(&vp->v_pollinfo->vpi_selinfo.si_note, (b), \
- (a) | KNF_NOKQLOCK); \
- } while (0)
-#define VN_KNOTE_LOCKED(vp, b) VN_KNOTE(vp, b, KNF_LISTLOCKED)
-#define VN_KNOTE_UNLOCKED(vp, b) VN_KNOTE(vp, b, 0)
+void vn_knote(struct vnode *vp, int hint, int flags);
+#define VN_KNOTE_LOCKED(vp, b) vn_knote(vp, b, KNF_LISTLOCKED)
+#define VN_KNOTE_UNLOCKED(vp, b) vn_knote(vp, b, 0)
/*
* Vnode flags.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Aug 8, 2:21 PM (15 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36233988
Default Alt Text
D56611.id176310.diff (13 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