Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Feb 2020 13:00:39 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r357962 - in head/sys: fs/tmpfs kern
Message-ID:  <202002151300.01FD0dma059583@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Sat Feb 15 13:00:39 2020
New Revision: 357962
URL: https://svnweb.freebsd.org/changeset/base/357962

Log:
  vfs: make write suspension mandatory
  
  At the time opt-in was introduced adding yourself as a writer was esrializing
  across the mount point. Nowadays it is fully per-cpu, the only impact being
  a small single-threaded hit on top of what's there right now.
  
  Vast majority of the overhead stems from the call to VOP_GETWRITEMOUNT which
  has is done regardless.
  
  Should someone want to microoptimize this single-threaded they can coalesce
  looking the mount up with adding a write to it.

Modified:
  head/sys/fs/tmpfs/tmpfs_vfsops.c
  head/sys/kern/vfs_vnops.c

Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_vfsops.c	Sat Feb 15 12:05:11 2020	(r357961)
+++ head/sys/fs/tmpfs/tmpfs_vfsops.c	Sat Feb 15 13:00:39 2020	(r357962)
@@ -88,7 +88,6 @@ static int	tmpfs_root(struct mount *, int flags, struc
 static int	tmpfs_fhtovp(struct mount *, struct fid *, int,
 		    struct vnode **);
 static int	tmpfs_statfs(struct mount *, struct statfs *);
-static void	tmpfs_susp_clean(struct mount *);
 
 static const char *tmpfs_opts[] = {
 	"from", "size", "maxfilesize", "inodes", "uid", "gid", "mode", "export",
@@ -646,14 +645,6 @@ tmpfs_sync(struct mount *mp, int waitfor)
 	return (0);
 }
 
-/*
- * The presence of a susp_clean method tells the VFS to track writes.
- */
-static void
-tmpfs_susp_clean(struct mount *mp __unused)
-{
-}
-
 static int
 tmpfs_init(struct vfsconf *conf)
 {
@@ -679,7 +670,6 @@ struct vfsops tmpfs_vfsops = {
 	.vfs_statfs =			tmpfs_statfs,
 	.vfs_fhtovp =			tmpfs_fhtovp,
 	.vfs_sync =			tmpfs_sync,
-	.vfs_susp_clean =		tmpfs_susp_clean,
 	.vfs_init =			tmpfs_init,
 	.vfs_uninit =			tmpfs_uninit,
 };

Modified: head/sys/kern/vfs_vnops.c
==============================================================================
--- head/sys/kern/vfs_vnops.c	Sat Feb 15 12:05:11 2020	(r357961)
+++ head/sys/kern/vfs_vnops.c	Sat Feb 15 13:00:39 2020	(r357962)
@@ -1643,13 +1643,6 @@ vn_closefile(struct file *fp, struct thread *td)
 	return (error);
 }
 
-static bool
-vn_suspendable(struct mount *mp)
-{
-
-	return (mp->mnt_op->vfs_susp_clean != NULL);
-}
-
 /*
  * Preparing to start a filesystem write operation. If the operation is
  * permitted, then we bump the count of operations in progress and
@@ -1729,12 +1722,6 @@ vn_start_write(struct vnode *vp, struct mount **mpp, i
 	if ((mp = *mpp) == NULL)
 		return (0);
 
-	if (!vn_suspendable(mp)) {
-		if (vp != NULL || (flags & V_MNTREF) != 0)
-			vfs_rel(mp);
-		return (0);
-	}
-
 	/*
 	 * VOP_GETWRITEMOUNT() returns with the mp refcount held through
 	 * a vfs_ref().
@@ -1780,12 +1767,6 @@ vn_start_secondary_write(struct vnode *vp, struct moun
 	if ((mp = *mpp) == NULL)
 		return (0);
 
-	if (!vn_suspendable(mp)) {
-		if (vp != NULL || (flags & V_MNTREF) != 0)
-			vfs_rel(mp);
-		return (0);
-	}
-
 	/*
 	 * VOP_GETWRITEMOUNT() returns with the mp refcount held through
 	 * a vfs_ref().
@@ -1829,7 +1810,7 @@ vn_finished_write(struct mount *mp)
 {
 	int c;
 
-	if (mp == NULL || !vn_suspendable(mp))
+	if (mp == NULL)
 		return;
 
 	if (vfs_op_thread_enter(mp)) {
@@ -1863,7 +1844,7 @@ vn_finished_write(struct mount *mp)
 void
 vn_finished_secondary_write(struct mount *mp)
 {
-	if (mp == NULL || !vn_suspendable(mp))
+	if (mp == NULL)
 		return;
 	MNT_ILOCK(mp);
 	MNT_REL(mp);
@@ -1884,8 +1865,6 @@ vfs_write_suspend(struct mount *mp, int flags)
 {
 	int error;
 
-	MPASS(vn_suspendable(mp));
-
 	vfs_op_enter(mp);
 
 	MNT_ILOCK(mp);
@@ -1934,8 +1913,6 @@ void
 vfs_write_resume(struct mount *mp, int flags)
 {
 
-	MPASS(vn_suspendable(mp));
-
 	MNT_ILOCK(mp);
 	if ((mp->mnt_kern_flag & MNTK_SUSPEND) != 0) {
 		KASSERT(mp->mnt_susp_owner == curthread, ("mnt_susp_owner"));
@@ -1970,7 +1947,6 @@ vfs_write_suspend_umnt(struct mount *mp)
 {
 	int error;
 
-	MPASS(vn_suspendable(mp));
 	KASSERT((curthread->td_pflags & TDP_IGNSUSP) == 0,
 	    ("vfs_write_suspend_umnt: recursed"));
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002151300.01FD0dma059583>