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
This commit is contained in:
+10
-12
@@ -2078,26 +2078,22 @@ vn_closefile(struct file *fp, struct thread *td)
|
|||||||
* suspension is over, and then proceed.
|
* suspension is over, and then proceed.
|
||||||
*/
|
*/
|
||||||
static int
|
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;
|
struct mount_pcpu *mpcpu;
|
||||||
int error, mflags;
|
int error, mflags;
|
||||||
|
|
||||||
if (__predict_true(!mplocked) && (flags & V_XSLEEP) == 0 &&
|
if ((flags & V_XSLEEP) == 0 && vfs_op_thread_enter(mp, mpcpu)) {
|
||||||
vfs_op_thread_enter(mp, mpcpu)) {
|
|
||||||
MPASS((mp->mnt_kern_flag & MNTK_SUSPEND) == 0);
|
MPASS((mp->mnt_kern_flag & MNTK_SUSPEND) == 0);
|
||||||
vfs_mp_count_add_pcpu(mpcpu, writeopcount, 1);
|
vfs_mp_count_add_pcpu(mpcpu, writeopcount, 1);
|
||||||
vfs_op_thread_exit(mp, mpcpu);
|
vfs_op_thread_exit(mp, mpcpu);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mplocked)
|
|
||||||
mtx_assert(MNT_MTX(mp), MA_OWNED);
|
|
||||||
else
|
|
||||||
MNT_ILOCK(mp);
|
|
||||||
|
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
|
MNT_ILOCK(mp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check on status of suspension.
|
* Check on status of suspension.
|
||||||
*/
|
*/
|
||||||
@@ -2165,7 +2161,7 @@ vn_start_write(struct vnode *vp, struct mount **mpp, int flags)
|
|||||||
if (vp == NULL)
|
if (vp == NULL)
|
||||||
vfs_ref(mp);
|
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)
|
if (error != 0 && (flags & V_NOWAIT) == 0)
|
||||||
*mpp = NULL;
|
*mpp = NULL;
|
||||||
return (error);
|
return (error);
|
||||||
@@ -2373,10 +2369,12 @@ vfs_write_resume(struct mount *mp, int flags)
|
|||||||
if ((flags & VR_NO_SUSPCLR) == 0)
|
if ((flags & VR_NO_SUSPCLR) == 0)
|
||||||
VFS_SUSP_CLEAN(mp);
|
VFS_SUSP_CLEAN(mp);
|
||||||
vfs_op_exit(mp);
|
vfs_op_exit(mp);
|
||||||
} else if ((flags & VR_START_WRITE) != 0) {
|
|
||||||
MNT_REF(mp);
|
|
||||||
vn_start_write_refed(mp, 0, true);
|
|
||||||
} else {
|
} else {
|
||||||
|
if ((flags & VR_START_WRITE) != 0) {
|
||||||
|
MNT_REF(mp);
|
||||||
|
mp->mnt_writeopcount++;
|
||||||
|
}
|
||||||
|
|
||||||
MNT_IUNLOCK(mp);
|
MNT_IUNLOCK(mp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user