Date: Thu, 23 Jul 2026 10:00:44 +0000 From: Olivier Certner <olce@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 9356619327e7 - stable/14 - vfs: Simplify vfs_write_resume()/vn_start_write_refed() Message-ID: <6a61e64c.3bb39.5d80ab4b@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=9356619327e726ee2e0453c2198102b562aa3a02 commit 9356619327e726ee2e0453c2198102b562aa3a02 Author: Olivier Certner <olce@FreeBSD.org> AuthorDate: 2026-03-27 12:43:24 +0000 Commit: Olivier Certner <olce@FreeBSD.org> CommitDate: 2026-07-23 09:59:05 +0000 vfs: Simplify vfs_write_resume()/vn_start_write_refed() The call to vn_start_write_refed() from vfs_write_resume() with 'mplocked' set to 'true' exactly boils down to doing an increment of 'mnt_writeopcount', albeit with lots of unnecessary verifications. Replace it with an inline incrementation. As the original call was the last with 'mplocked' with 'true', remove the 'mplocked' parameter from vfs_write_resume(), simplifying its code accordingly ('mplocked' always false). While here, in vfs_write_resume(), initialize 'error' out of the mount lock. Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D56108 (cherry picked from commit 4deb934c1a1051d7ef41e9309d066742722ce180) --- sys/kern/vfs_vnops.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index ee247de2374c..1e97d2260ac9 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1971,26 +1971,22 @@ vn_closefile(struct file *fp, struct thread *td) * suspension is over, and then proceed. */ static int -vn_start_write_refed(struct mount *mp, int flags, bool mplocked) +vn_start_write_refed(struct mount *mp, int flags) { struct mount_pcpu *mpcpu; int error, mflags; - if (__predict_true(!mplocked) && (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); return (0); } - if (mplocked) - mtx_assert(MNT_MTX(mp), MA_OWNED); - else - MNT_ILOCK(mp); - error = 0; + MNT_ILOCK(mp); + /* * Check on status of suspension. */ @@ -2058,7 +2054,7 @@ vn_start_write(struct vnode *vp, struct mount **mpp, int flags) if (vp == NULL) vfs_ref(mp); - error = vn_start_write_refed(mp, flags, false); + error = vn_start_write_refed(mp, flags); if (error != 0 && (flags & V_NOWAIT) == 0) *mpp = NULL; return (error); @@ -2266,10 +2262,12 @@ vfs_write_resume(struct mount *mp, int flags) if ((flags & VR_NO_SUSPCLR) == 0) VFS_SUSP_CLEAN(mp); vfs_op_exit(mp); - } else if ((flags & VR_START_WRITE) != 0) { - MNT_REF(mp); - vn_start_write_refed(mp, 0, true); } else { + if ((flags & VR_START_WRITE) != 0) { + MNT_REF(mp); + mp->mnt_writeopcount++; + } + MNT_IUNLOCK(mp); } }home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a61e64c.3bb39.5d80ab4b>
