From nobody Sun Jun 21 10:15:56 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gjnKT1hmGz6jR7J for ; Sun, 21 Jun 2026 10:15:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gjnKS6tykz3HSX for ; Sun, 21 Jun 2026 10:15:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782036957; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=06bsfDguF9RQA+HloxadAA8GRSM/Ww3FQ1gZ24UjvnE=; b=EpL8dz5qwMaVM9RA0gOAiqxTgjtu6wtKrXnEtXs6FJYlguJO0Sm9M4hgbBDe43fOaE0Jdy oTHN542whh6J+PYLWgxMEpv62m9yZHUS6j9iwdgY+ix50aX+miyNa6jO8y97UjAYv1GQp2 RbuhearWdDInsLHu7QRVc6NQS4ZIWEMkOarmX5Dcj03UXXLvYid0frMPP54ieov3Uc8fcL +QyKVv+7NxBa/cihhQa+ImoNWVpjcQ7Jo2QgoIxTBZ0mI4CV3uvaB5mfymhiE1yYipg/69 coXcZUSeERVAl1ZNNsVU/wXceZsYReOYu0Cpame5234+hchbDgJvnjWw0IVagw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782036957; a=rsa-sha256; cv=none; b=SJewKPVlw1WfpyJ9yFmP1NHMOMUOjXir+fupacTqlf2QuC4nmjg6zpVQMacIWbucG77q9T ZX6zHjuNzUfOlSHf1fzzcFVKlRyMT6c1e02xW/6G59re9Gyu20USs3PzNBls+WulDhNU/Q CYn1XYInvw1ftO7BbdWWssYCocS9bP25+/fS/bUaKHtsGv9OcTGLongr870pjRFyiE9WC4 BCdVOtltmLio8kAx3qr/IqQMxv8qZKdaYdc2g/OYESioM+2TntisWMaeGR72ROGb/r0l1Z CQVwC0wSIP8t+f86MS+r1O+UsRfcDWuMvzVLSRYVvcSe6/5lBdTe9O/xRjOPNA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782036957; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=06bsfDguF9RQA+HloxadAA8GRSM/Ww3FQ1gZ24UjvnE=; b=KRx8qYyx1e7bK3NMkYT6jOReqUTeS94JDfGDqHexZA0RC76gAPsSDRqVQ8pzvL+LN5yBn0 T4xKph9rpbuBgLKRV2Ng5oftJ2mDC8QUcGYZ3JnpTdd6/7JlgUkCwxvWQYi1i6MmZ735uh IyVXDds1PwwpqCqnZ8w4ce1r7NorMb2HrwuXu7TBp/wVPKXE5Nkf4okQiZv6ERaB4RkdFY pXGwEtCB25RSiI5D7P1Xcna0xky2Mf5tM2JmFWHIvBQuCO2T+v8ca5fe1uBhsvkUTUhxc0 NpNLFmCzdx64S8gx6JPYcllCvHLGDWQNgMRlpkhvpnJITAVU4HOJMha1gsSNiw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gjnKS5s2tz1BTT for ; Sun, 21 Jun 2026 10:15:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 19fd7 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 21 Jun 2026 10:15:56 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 049c784eae5d - stable/15 - vfs: convert vfs_op_thread_* macros to static inlines List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 049c784eae5d482e78df7e2202e6e16944d2cdb0 Auto-Submitted: auto-generated Date: Sun, 21 Jun 2026 10:15:56 +0000 Message-Id: <6a37b9dc.19fd7.7a25b88@gitrepo.freebsd.org> The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=049c784eae5d482e78df7e2202e6e16944d2cdb0 commit 049c784eae5d482e78df7e2202e6e16944d2cdb0 Author: Konstantin Belousov AuthorDate: 2026-04-24 01:26:11 +0000 Commit: Konstantin Belousov CommitDate: 2026-06-21 10:05:27 +0000 vfs: convert vfs_op_thread_* macros to static inlines (cherry picked from commit 32cf4514cad66ff69ffc96ede20d8debc9b96790) --- sys/kern/vfs_cache.c | 4 +-- sys/kern/vfs_mount.c | 6 ++-- sys/kern/vfs_subr.c | 6 ++-- sys/kern/vfs_vnops.c | 4 +-- sys/sys/mount.h | 97 +++++++++++++++++++++++++++++++--------------------- 5 files changed, 68 insertions(+), 49 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index a5e28665aed9..822c2e19ad04 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -5713,7 +5713,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)); @@ -5768,7 +5768,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 9cea2d8acc64..0a3cce26ee48 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 d2894858fc94..01387b66392f 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); @@ -6978,7 +6978,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 1746d344aa64..a3ee9216645c 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2087,7 +2087,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); @@ -2256,7 +2256,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/mount.h b/sys/sys/mount.h index 18f85192f6c3..1564d2cc22c4 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -36,8 +36,10 @@ #include #include #ifdef _KERNEL +#include #include #include +#include #include #include #include @@ -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; \ -}) - -#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); \