Page MenuHomeFreeBSD

D56611.id176684.diff
No OneTemporary

D56611.id176684.diff

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);
@@ -5817,6 +5817,15 @@
}
#endif /* INVARIANTS */
+static bool
+vop_check_pollinfo(struct vnode *vp, int rc)
+{
+ return (rc == 0 &&
+ (vn_irflag_read(vp) & (VIRF_KNOTE | VIRF_INOTIFY)) != 0);
+}
+#define vop_check_pollinfo(vp, rc) \
+ __predict_false((vop_check_pollinfo)((vp), (rc)))
+
void
vop_rename_fail(struct vop_rename_args *ap)
{
@@ -6093,7 +6102,7 @@
a = ap;
dvp = a->a_dvp;
vn_seqc_write_end(dvp);
- if (!rc) {
+ if (rc == 0) {
VFS_KNOTE_LOCKED(dvp, NOTE_WRITE);
INOTIFY_NAME(*a->a_vpp, dvp, a->a_cnp, IN_CREATE);
}
@@ -6151,7 +6160,7 @@
a = ap;
vp = a->a_vp;
vn_seqc_write_end(vp);
- if (!rc) {
+ if (vop_check_pollinfo(vp, rc)) {
VFS_KNOTE_LOCKED(a->a_vp, NOTE_ATTRIB);
INOTIFY(vp, IN_ATTRIB);
}
@@ -6181,7 +6190,7 @@
tdvp = a->a_tdvp;
vn_seqc_write_end(vp);
vn_seqc_write_end(tdvp);
- if (!rc) {
+ if (rc == 0) {
VFS_KNOTE_LOCKED(vp, NOTE_LINK);
VFS_KNOTE_LOCKED(tdvp, NOTE_WRITE);
INOTIFY_NAME(vp, tdvp, a->a_cnp, _IN_ATTRIB_LINKCOUNT);
@@ -6209,7 +6218,7 @@
a = ap;
dvp = a->a_dvp;
vn_seqc_write_end(dvp);
- if (!rc) {
+ if (rc == 0) {
VFS_KNOTE_LOCKED(dvp, NOTE_WRITE | NOTE_LINK);
INOTIFY_NAME(*a->a_vpp, dvp, a->a_cnp, IN_CREATE);
}
@@ -6247,7 +6256,7 @@
a = ap;
dvp = a->a_dvp;
vn_seqc_write_end(dvp);
- if (!rc) {
+ if (rc == 0) {
VFS_KNOTE_LOCKED(dvp, NOTE_WRITE);
INOTIFY_NAME(*a->a_vpp, dvp, a->a_cnp, IN_CREATE);
}
@@ -6262,7 +6271,8 @@
a = ap;
vp = a->a_vp;
ASSERT_VOP_IN_SEQC(vp);
- if (!rc) {
+
+ if (vop_check_pollinfo(vp, rc)) {
VFS_KNOTE_LOCKED(vp, NOTE_REVOKE);
INOTIFY_REVOKE(vp);
}
@@ -6293,7 +6303,7 @@
vp = a->a_vp;
vn_seqc_write_end(dvp);
vn_seqc_write_end(vp);
- if (!rc) {
+ if (rc == 0) {
VFS_KNOTE_LOCKED(dvp, NOTE_WRITE);
VFS_KNOTE_LOCKED(vp, NOTE_DELETE);
INOTIFY_NAME(vp, dvp, a->a_cnp, _IN_ATTRIB_LINKCOUNT);
@@ -6366,7 +6376,7 @@
vp = a->a_vp;
vn_seqc_write_end(dvp);
vn_seqc_write_end(vp);
- if (!rc) {
+ if (rc == 0) {
vp->v_vflag |= VV_UNLINKED;
VFS_KNOTE_LOCKED(dvp, NOTE_WRITE | NOTE_LINK);
VFS_KNOTE_LOCKED(vp, NOTE_DELETE);
@@ -6394,7 +6404,7 @@
a = ap;
vp = a->a_vp;
vn_seqc_write_end(vp);
- if (!rc) {
+ if (vop_check_pollinfo(vp, rc)) {
VFS_KNOTE_LOCKED(vp, NOTE_ATTRIB);
INOTIFY(vp, IN_ATTRIB);
}
@@ -6442,7 +6452,7 @@
a = ap;
vp = a->a_vp;
vn_seqc_write_end(vp);
- if (!rc) {
+ if (vop_check_pollinfo(vp, rc)) {
VFS_KNOTE_LOCKED(vp, NOTE_ATTRIB);
INOTIFY(vp, IN_ATTRIB);
}
@@ -6468,7 +6478,7 @@
a = ap;
dvp = a->a_dvp;
vn_seqc_write_end(dvp);
- if (!rc) {
+ if (rc == 0) {
VFS_KNOTE_LOCKED(dvp, NOTE_WRITE);
INOTIFY_NAME(*a->a_vpp, dvp, a->a_cnp, IN_CREATE);
}
@@ -6479,7 +6489,7 @@
{
struct vop_open_args *a = ap;
- if (!rc) {
+ if (vop_check_pollinfo(a->a_vp, rc)) {
VFS_KNOTE_LOCKED(a->a_vp, NOTE_OPEN);
INOTIFY(a->a_vp, IN_OPEN);
}
@@ -6490,8 +6500,9 @@
{
struct vop_close_args *a = ap;
- if (!rc && (a->a_cred != NOCRED || /* filter out revokes */
- !VN_IS_DOOMED(a->a_vp))) {
+ if (rc == 0 && (a->a_cred != NOCRED || /* filter out revokes */
+ !VN_IS_DOOMED(a->a_vp)) &&
+ vop_check_pollinfo(a->a_vp, rc)) {
VFS_KNOTE_LOCKED(a->a_vp, (a->a_fflag & FWRITE) != 0 ?
NOTE_CLOSE_WRITE : NOTE_CLOSE);
INOTIFY(a->a_vp, (a->a_fflag & FWRITE) != 0 ?
@@ -6504,7 +6515,7 @@
{
struct vop_read_args *a = ap;
- if (!rc) {
+ if (vop_check_pollinfo(a->a_vp, rc)) {
VFS_KNOTE_LOCKED(a->a_vp, NOTE_READ);
INOTIFY(a->a_vp, IN_ACCESS);
}
@@ -6515,7 +6526,7 @@
{
struct vop_read_pgcache_args *a = ap;
- if (!rc)
+ if (rc == 0)
VFS_KNOTE_UNLOCKED(a->a_vp, NOTE_READ);
}
@@ -6662,6 +6673,8 @@
{
struct vnode *vp = arg;
+ if (KNLIST_EMPTY(&vp->v_pollinfo->vpi_selinfo.si_note))
+ vn_irflag_unset(vp, VIRF_KNOTE);
VOP_UNLOCK(vp);
}
@@ -6709,7 +6722,11 @@
return (ENOMEM);
knl = &vp->v_pollinfo->vpi_selinfo.si_note;
vhold(vp);
- knlist_add(knl, kn, 0);
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+ knlist_add(knl, kn, 1);
+ if ((vn_irflag_read(vp) & VIRF_KNOTE) == 0)
+ vn_irflag_set(vp, VIRF_KNOTE);
+ VOP_UNLOCK(vp);
return (0);
}
@@ -6988,7 +7005,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>
@@ -851,114 +853,134 @@
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)
+#include <sys/vnode.h>
+
+static inline void
+VFS_KNOTE_LOCKED(struct vnode *vp, int hint)
+{
+ if ((vn_irflag_read(vp) & VIRF_KNOTE) != 0) {
+ KNOTE_LOCKED(&vp->v_pollinfo->vpi_selinfo.si_note,
+ hint);
+ }
+}
+
+static inline void
+VFS_KNOTE_UNLOCKED(struct vnode *vp, int hint)
+{
+ if ((vn_irflag_read(vp) & VIRF_KNOTE) != 0) {
+ KNOTE_UNLOCKED(&vp->v_pollinfo->vpi_selinfo.si_note,
+ hint);
+ }
+}
#include <sys/module.h>
@@ -1138,47 +1160,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
@@ -222,21 +222,17 @@
#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))
-
-#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)
+#define VN_KNOTE(vp, b, a) \
+do { \
+ if ((vn_irflag_read(vp) & VIRF_KNOTE) != 0) { \
+ 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)
/*
* Vnode flags.
@@ -261,6 +257,7 @@
#define VIRF_INOTIFY 0x0080 /* This vnode is being watched */
#define VIRF_INOTIFY_PARENT 0x0100 /* A parent of this vnode may be being
watched */
+#define VIRF_KNOTE 0x0200 /* Has knlist */
#define VI_UNUSED0 0x0001 /* unused */
#define VI_MOUNT 0x0002 /* Mount in progress */
@@ -1053,7 +1050,7 @@
off_t osize, ooffset, noffset; \
\
osize = ooffset = noffset = 0; \
- if (!VN_KNLIST_EMPTY((ap)->a_vp)) { \
+ if ((vn_irflag_read((ap)->a_vp) & VIRF_KNOTE) != 0) { \
error = VOP_GETATTR((ap)->a_vp, &va, (ap)->a_cred); \
if (error) \
return (error); \
@@ -1064,7 +1061,7 @@
#define vop_write_post(ap, ret) \
noffset = (ap)->a_uio->uio_offset; \
if (noffset > ooffset) { \
- if (!VN_KNLIST_EMPTY((ap)->a_vp)) { \
+ if ((vn_irflag_read((ap)->a_vp) & VIRF_KNOTE) != 0) { \
VFS_KNOTE_LOCKED((ap)->a_vp, NOTE_WRITE | \
(noffset > osize ? NOTE_EXTEND : 0)); \
} \

File Metadata

Mime Type
text/plain
Expires
Fri, May 1, 8:17 AM (9 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32565284
Default Alt Text
D56611.id176684.diff (18 KB)

Event Timeline