git: 4deb934c1a10 - main - vfs: Simplify vfs_write_resume()/vn_start_write_refed()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 30 Mar 2026 09:25:12 UTC
The branch main has been updated by olce:
URL: https://cgit.FreeBSD.org/src/commit/?id=4deb934c1a1051d7ef41e9309d066742722ce180
commit 4deb934c1a1051d7ef41e9309d066742722ce180
Author: Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2026-03-27 12:43:24 +0000
Commit: Olivier Certner <olce@FreeBSD.org>
CommitDate: 2026-03-30 09:24:23 +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
---
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 ea8f8437b743..4061b2272193 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -2078,26 +2078,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.
*/
@@ -2165,7 +2161,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);
@@ -2373,10 +2369,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);
}
}