diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2026-05-03 20:10:06 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2026-05-03 20:12:03 +0000 |
| commit | 9ca9a79ea67e8569c31ecc328e001b35908f491c (patch) | |
| tree | 91fcb6478b9b7dd0614770d777c4d006c775cb60 /sys | |
| parent | f193f5a749b696e6c05fa2c47c24522b1624b1a7 (diff) | |
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/kern/vfs_bio.c | 3 | ||||
| -rw-r--r-- | sys/kern/vfs_cache.c | 4 | ||||
| -rw-r--r-- | sys/kern/vfs_mount.c | 6 | ||||
| -rw-r--r-- | sys/kern/vfs_subr.c | 57 | ||||
| -rw-r--r-- | sys/kern/vfs_vnops.c | 4 | ||||
| -rw-r--r-- | sys/sys/fcntl.h | 7 | ||||
| -rw-r--r-- | sys/sys/mount.h | 293 | ||||
| -rw-r--r-- | sys/sys/rangelock.h | 6 | ||||
| -rw-r--r-- | sys/sys/vnode.h | 28 |
9 files changed, 170 insertions, 238 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 675f6fb4e526..8f47a7abbc5e 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -727,8 +727,7 @@ bufspace_wait(struct bufdomain *bd, struct vnode *vp, int gbflags, BD_LOCK(bd); while (bd->bd_wanted) { if (vp != NULL && vp->v_type != VCHR && - (td->td_pflags & TDP_BUFNEED) == 0 && - vp->v_bufobj.bo_dirty.bv_cnt > 0) { + (td->td_pflags & TDP_BUFNEED) == 0) { BD_UNLOCK(bd); /* * getblk() is called with a vnode locked, and diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 66210bf58a7c..3f8591bd0ba7 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -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)) { diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index fff05a627162..ddc5a1b70887 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -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; diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 57de07ffaa12..58975f7ac932 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -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); @@ -5817,15 +5817,6 @@ assert_vop_elocked(struct vnode *vp, const char *str) } #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) { @@ -6102,7 +6093,7 @@ vop_create_post(void *ap, int rc) a = ap; dvp = a->a_dvp; vn_seqc_write_end(dvp); - if (rc == 0) { + if (!rc) { VFS_KNOTE_LOCKED(dvp, NOTE_WRITE); INOTIFY_NAME(*a->a_vpp, dvp, a->a_cnp, IN_CREATE); } @@ -6160,7 +6151,7 @@ vop_deleteextattr_post(void *ap, int rc) a = ap; vp = a->a_vp; vn_seqc_write_end(vp); - if (vop_check_pollinfo(vp, rc)) { + if (!rc) { VFS_KNOTE_LOCKED(a->a_vp, NOTE_ATTRIB); INOTIFY(vp, IN_ATTRIB); } @@ -6190,7 +6181,7 @@ vop_link_post(void *ap, int rc) tdvp = a->a_tdvp; vn_seqc_write_end(vp); vn_seqc_write_end(tdvp); - if (rc == 0) { + if (!rc) { VFS_KNOTE_LOCKED(vp, NOTE_LINK); VFS_KNOTE_LOCKED(tdvp, NOTE_WRITE); INOTIFY_NAME(vp, tdvp, a->a_cnp, _IN_ATTRIB_LINKCOUNT); @@ -6218,7 +6209,7 @@ vop_mkdir_post(void *ap, int rc) a = ap; dvp = a->a_dvp; vn_seqc_write_end(dvp); - if (rc == 0) { + if (!rc) { VFS_KNOTE_LOCKED(dvp, NOTE_WRITE | NOTE_LINK); INOTIFY_NAME(*a->a_vpp, dvp, a->a_cnp, IN_CREATE); } @@ -6256,7 +6247,7 @@ vop_mknod_post(void *ap, int rc) a = ap; dvp = a->a_dvp; vn_seqc_write_end(dvp); - if (rc == 0) { + if (!rc) { VFS_KNOTE_LOCKED(dvp, NOTE_WRITE); INOTIFY_NAME(*a->a_vpp, dvp, a->a_cnp, IN_CREATE); } @@ -6271,8 +6262,7 @@ vop_reclaim_post(void *ap, int rc) a = ap; vp = a->a_vp; ASSERT_VOP_IN_SEQC(vp); - - if (vop_check_pollinfo(vp, rc)) { + if (!rc) { VFS_KNOTE_LOCKED(vp, NOTE_REVOKE); INOTIFY_REVOKE(vp); } @@ -6303,7 +6293,7 @@ vop_remove_post(void *ap, int rc) vp = a->a_vp; vn_seqc_write_end(dvp); vn_seqc_write_end(vp); - if (rc == 0) { + if (!rc) { VFS_KNOTE_LOCKED(dvp, NOTE_WRITE); VFS_KNOTE_LOCKED(vp, NOTE_DELETE); INOTIFY_NAME(vp, dvp, a->a_cnp, _IN_ATTRIB_LINKCOUNT); @@ -6376,7 +6366,7 @@ vop_rmdir_post(void *ap, int rc) vp = a->a_vp; vn_seqc_write_end(dvp); vn_seqc_write_end(vp); - if (rc == 0) { + if (!rc) { vp->v_vflag |= VV_UNLINKED; VFS_KNOTE_LOCKED(dvp, NOTE_WRITE | NOTE_LINK); VFS_KNOTE_LOCKED(vp, NOTE_DELETE); @@ -6404,7 +6394,7 @@ vop_setattr_post(void *ap, int rc) a = ap; vp = a->a_vp; vn_seqc_write_end(vp); - if (vop_check_pollinfo(vp, rc)) { + if (!rc) { VFS_KNOTE_LOCKED(vp, NOTE_ATTRIB); INOTIFY(vp, IN_ATTRIB); } @@ -6452,7 +6442,7 @@ vop_setextattr_post(void *ap, int rc) a = ap; vp = a->a_vp; vn_seqc_write_end(vp); - if (vop_check_pollinfo(vp, rc)) { + if (!rc) { VFS_KNOTE_LOCKED(vp, NOTE_ATTRIB); INOTIFY(vp, IN_ATTRIB); } @@ -6478,7 +6468,7 @@ vop_symlink_post(void *ap, int rc) a = ap; dvp = a->a_dvp; vn_seqc_write_end(dvp); - if (rc == 0) { + if (!rc) { VFS_KNOTE_LOCKED(dvp, NOTE_WRITE); INOTIFY_NAME(*a->a_vpp, dvp, a->a_cnp, IN_CREATE); } @@ -6489,7 +6479,7 @@ vop_open_post(void *ap, int rc) { struct vop_open_args *a = ap; - if (vop_check_pollinfo(a->a_vp, rc)) { + if (!rc) { VFS_KNOTE_LOCKED(a->a_vp, NOTE_OPEN); INOTIFY(a->a_vp, IN_OPEN); } @@ -6500,9 +6490,8 @@ vop_close_post(void *ap, int rc) { struct vop_close_args *a = ap; - if (rc == 0 && (a->a_cred != NOCRED || /* filter out revokes */ - !VN_IS_DOOMED(a->a_vp)) && - vop_check_pollinfo(a->a_vp, rc)) { + if (!rc && (a->a_cred != NOCRED || /* filter out revokes */ + !VN_IS_DOOMED(a->a_vp))) { 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 ? @@ -6515,7 +6504,7 @@ vop_read_post(void *ap, int rc) { struct vop_read_args *a = ap; - if (vop_check_pollinfo(a->a_vp, rc)) { + if (!rc) { VFS_KNOTE_LOCKED(a->a_vp, NOTE_READ); INOTIFY(a->a_vp, IN_ACCESS); } @@ -6526,7 +6515,7 @@ vop_read_pgcache_post(void *ap, int rc) { struct vop_read_pgcache_args *a = ap; - if (rc == 0) + if (!rc) VFS_KNOTE_UNLOCKED(a->a_vp, NOTE_READ); } @@ -6673,8 +6662,6 @@ vfs_knlunlock(void *arg) { struct vnode *vp = arg; - if (KNLIST_EMPTY(&vp->v_pollinfo->vpi_selinfo.si_note)) - vn_irflag_unset(vp, VIRF_KNOTE); VOP_UNLOCK(vp); } @@ -6722,11 +6709,7 @@ vfs_kqfilter(struct vop_kqfilter_args *ap) return (ENOMEM); knl = &vp->v_pollinfo->vpi_selinfo.si_note; vhold(vp); - 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); + knlist_add(knl, kn, 0); return (0); } @@ -7005,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)) { diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 15704634ff62..4061b2272193 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -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); diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h index bf64d06f2a4d..0b13241f0ee3 100644 --- a/sys/sys/fcntl.h +++ b/sys/sys/fcntl.h @@ -142,13 +142,6 @@ typedef __pid_t pid_t; #define O_EMPTY_PATH 0x02000000 #define O_NAMEDATTR 0x04000000 /* NFSv4 named attributes */ #define O_XATTR O_NAMEDATTR /* Solaris compatibility */ - -/* - * Emulate MacOSX compatibility flag without consuming a flags bit. - * Selected bits set does not define a useful open request and is - * unlikely to be specified by reasonable code. - */ -#define O_SYMLINK (O_PATH | O_DSYNC | O_DIRECT) #endif #if __POSIX_VISIBLE >= 202405 diff --git a/sys/sys/mount.h b/sys/sys/mount.h index c96ce7d7b080..18f85192f6c3 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -36,10 +36,8 @@ #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> @@ -853,134 +851,114 @@ struct vfsops { vfs_statfs_t __vfs_statfs; -static inline int -VFS_MOUNT(struct mount *mp) -{ - int rc; +#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; }) - 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_UNMOUNT(MP, FORCE) ({ \ + int _rc; \ + \ + _rc = (*(MP)->mnt_op->vfs_unmount)(MP, FORCE); \ + _rc; }) -static inline int -VFS_UNMOUNT(struct mount *mp, int force) -{ - return (mp->mnt_op->vfs_unmount(mp, force)); -} +#define VFS_ROOT(MP, FLAGS, VPP) ({ \ + int _rc; \ + \ + _rc = (*(MP)->mnt_op->vfs_root)(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_CACHEDROOT(MP, FLAGS, VPP) ({ \ + int _rc; \ + \ + _rc = (*(MP)->mnt_op->vfs_cachedroot)(MP, FLAGS, VPP); \ + _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_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_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_STATFS(MP, SBP) ({ \ + int _rc; \ + \ + _rc = __vfs_statfs((MP), (SBP)); \ + _rc; }) -static inline int -VFS_STATFS(struct mount *mp, struct statfs *sbp) -{ - return (__vfs_statfs(mp, sbp)); -} +#define VFS_SYNC(MP, WAIT) ({ \ + int _rc; \ + \ + _rc = (*(MP)->mnt_op->vfs_sync)(MP, WAIT); \ + _rc; }) -static inline int -VFS_SYNC(struct mount *mp, int waitfor) -{ - return (mp->mnt_op->vfs_sync(mp, waitfor)); -} +#define VFS_VGET(MP, INO, FLAGS, VPP) ({ \ + int _rc; \ + \ + _rc = (*(MP)->mnt_op->vfs_vget)(MP, INO, 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)); -} - -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_FHTOVP(MP, FIDP, FLAGS, VPP) ({ \ + int _rc; \ + \ + _rc = (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, FLAGS, VPP); \ + _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_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_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_EXTATTRCTL(MP, C, FN, NS, N) ({ \ + int _rc; \ + \ + _rc = (*(MP)->mnt_op->vfs_extattrctl)(MP, C, FN, NS, N); \ + _rc; }) -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_SYSCTL(MP, OP, REQ) ({ \ + int _rc; \ + \ + _rc = (*(MP)->mnt_op->vfs_sysctl)(MP, OP, REQ); \ + _rc; }) -static inline void -VFS_SUSP_CLEAN(struct mount *mp) -{ - if (mp->mnt_op->vfs_susp_clean != NULL) - mp->mnt_op->vfs_susp_clean(mp); -} - -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_SUSP_CLEAN(MP) do { \ + if (*(MP)->mnt_op->vfs_susp_clean != NULL) { \ + (*(MP)->mnt_op->vfs_susp_clean)(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_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_PURGE(struct mount *mp) -{ - if (mp->mnt_op->vfs_purge != NULL) - mp->mnt_op->vfs_purge(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) -#include <sys/vnode.h> +#define VFS_PURGE(MP) do { \ + if (*(MP)->mnt_op->vfs_purge != NULL) { \ + (*(MP)->mnt_op->vfs_purge)(MP); \ + } \ +} while (0) -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); - } -} +#define VFS_KNOTE_LOCKED(vp, hint) do \ +{ \ + VN_KNOTE((vp), (hint), KNF_LISTLOCKED); \ +} while (0) -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); - } -} +#define VFS_KNOTE_UNLOCKED(vp, hint) do \ +{ \ + VN_KNOTE((vp), (hint), 0); \ +} while (0) #include <sys/module.h> @@ -1160,64 +1138,47 @@ 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); - -static inline bool -vfs_op_thread_entered(struct mount *mp) -{ - struct mount_pcpu *mpcpu = vfs_mount_pcpu(mp); - - 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; +#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; \ +}) - critical_enter(); - retval = vfs_op_thread_enter_crit(mp, mpcpup); - if (__predict_false(!retval)) - critical_exit(); - return (retval); -} +#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; \ +}) -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); +#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; \ +}) - atomic_interrupt_fence(); - mpcpu->mntp_thread_in_ops = 0; -} +#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 void -vfs_op_thread_exit(struct mount *mp, struct mount_pcpu *mpcpu) -{ - vfs_op_thread_exit_crit(mp, mpcpu); - critical_exit(); -} +#define vfs_op_thread_exit(mp, _mpcpu) do { \ + vfs_op_thread_exit_crit(mp, _mpcpu); \ + critical_exit(); \ +} while (0) #define vfs_mp_count_add_pcpu(_mpcpu, count, val) do { \ MPASS(_mpcpu->mntp_thread_in_ops == 1); \ diff --git a/sys/sys/rangelock.h b/sys/sys/rangelock.h index 00fe7eee851e..32ccf3427b49 100644 --- a/sys/sys/rangelock.h +++ b/sys/sys/rangelock.h @@ -46,16 +46,10 @@ struct rl_q_entry; * all existing lock owners are compatible with the request. Two lock * owners are compatible if their ranges do not overlap, or both * owners are for read. - * - * The resvX fields can be used by consumers. For instance, struct - * vnode uses resv1 as v_vrflag. */ struct rangelock { uintptr_t head; bool sleepers; - uint8_t resv0; - uint16_t resv1; - uint32_t resv2; }; #ifdef _KERNEL diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 70340faca1b4..3fd2c770cda1 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -203,7 +203,6 @@ struct vnode { (negative) text users */ int v_seqc_users; /* i modifications pending */ }; -#define v_vrflag v_rl.resv1 #define VN_ISDEV(vp) VTYPE_ISDEV((vp)->v_type) @@ -222,17 +221,21 @@ _Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes"); #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 -#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) +/* 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) /* * Vnode flags. @@ -257,7 +260,6 @@ do { \ #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 */ @@ -1050,7 +1052,7 @@ void vop_rename_fail(struct vop_rename_args *ap); off_t osize, ooffset, noffset; \ \ osize = ooffset = noffset = 0; \ - if ((vn_irflag_read((ap)->a_vp) & VIRF_KNOTE) != 0) { \ + if (!VN_KNLIST_EMPTY((ap)->a_vp)) { \ error = VOP_GETATTR((ap)->a_vp, &va, (ap)->a_cred); \ if (error) \ return (error); \ @@ -1061,7 +1063,7 @@ void vop_rename_fail(struct vop_rename_args *ap); #define vop_write_post(ap, ret) \ noffset = (ap)->a_uio->uio_offset; \ if (noffset > ooffset) { \ - if ((vn_irflag_read((ap)->a_vp) & VIRF_KNOTE) != 0) { \ + if (!VN_KNLIST_EMPTY((ap)->a_vp)) { \ VFS_KNOTE_LOCKED((ap)->a_vp, NOTE_WRITE | \ (noffset > osize ? NOTE_EXTEND : 0)); \ } \ |
