Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Oct 2014 06:59:33 +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: r273271 - in head/sys: fs/tmpfs kern sys
Message-ID:  <201410190659.s9J6xXQE034746@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Sun Oct 19 06:59:33 2014
New Revision: 273271
URL: https://svnweb.freebsd.org/changeset/base/273271

Log:
  Provide vfs suspension support only for filesystems which need it.
  
  Need is expressed by providing vfs_susp_clean function in vfsops.
  
  Differential Revision:	D952
  Reviewed by:	kib (previous version)
  MFC after:	2 weeks

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

Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_vfsops.c	Sun Oct 19 04:38:02 2014	(r273270)
+++ head/sys/fs/tmpfs/tmpfs_vfsops.c	Sun Oct 19 06:59:33 2014	(r273271)
@@ -427,6 +427,14 @@ tmpfs_sync(struct mount *mp, int waitfor
 }
 
 /*
+ * A stub created so that vfs does vn_start_write for this filesystem
+ */
+static void
+tmpfs_susp_clean(struct mount *mp)
+{
+}
+
+/*
  * tmpfs vfs operations.
  */
 
@@ -437,5 +445,6 @@ struct vfsops tmpfs_vfsops = {
 	.vfs_statfs =			tmpfs_statfs,
 	.vfs_fhtovp =			tmpfs_fhtovp,
 	.vfs_sync =			tmpfs_sync,
+	.vfs_susp_clean =		tmpfs_susp_clean,
 };
 VFS_SET(tmpfs_vfsops, tmpfs, VFCF_JAIL);

Modified: head/sys/kern/vfs_vnops.c
==============================================================================
--- head/sys/kern/vfs_vnops.c	Sun Oct 19 04:38:02 2014	(r273270)
+++ head/sys/kern/vfs_vnops.c	Sun Oct 19 06:59:33 2014	(r273271)
@@ -1572,6 +1572,25 @@ vn_closefile(fp, td)
 	return (error);
 }
 
+static bool
+vn_suspendable_mp(struct mount *mp)
+{
+
+	return (mp->mnt_op->vfs_susp_clean != NULL);
+}
+
+static bool
+vn_suspendable(struct vnode *vp, struct mount **mpp)
+{
+
+	if (vp != NULL)
+		*mpp = vp->v_mount;
+	if (*mpp == NULL)
+		return (false);
+
+	return (vn_suspendable_mp(*mpp));
+}
+
 /*
  * Preparing to start a filesystem write operation. If the operation is
  * permitted, then we bump the count of operations in progress and
@@ -1621,6 +1640,9 @@ vn_start_write(vp, mpp, flags)
 	struct mount *mp;
 	int error;
 
+	if (!vn_suspendable(vp, mpp))
+		return (0);
+
 	error = 0;
 	/*
 	 * If a vnode is provided, get and return the mount point that
@@ -1667,6 +1689,9 @@ vn_start_secondary_write(vp, mpp, flags)
 	struct mount *mp;
 	int error;
 
+	if (!vn_suspendable(vp, mpp))
+		return (0);
+
  retry:
 	if (vp != NULL) {
 		if ((error = VOP_GETWRITEMOUNT(vp, mpp)) != 0) {
@@ -1724,7 +1749,7 @@ void
 vn_finished_write(mp)
 	struct mount *mp;
 {
-	if (mp == NULL)
+	if (mp == NULL || !vn_suspendable_mp(mp))
 		return;
 	MNT_ILOCK(mp);
 	MNT_REL(mp);
@@ -1747,7 +1772,7 @@ void
 vn_finished_secondary_write(mp)
 	struct mount *mp;
 {
-	if (mp == NULL)
+	if (mp == NULL || !vn_suspendable_mp(mp))
 		return;
 	MNT_ILOCK(mp);
 	MNT_REL(mp);
@@ -1770,6 +1795,8 @@ vfs_write_suspend(struct mount *mp, int 
 {
 	int error;
 
+	MPASS(vn_suspendable_mp(mp));
+
 	MNT_ILOCK(mp);
 	if (mp->mnt_susp_owner == curthread) {
 		MNT_IUNLOCK(mp);
@@ -1811,6 +1838,8 @@ void
 vfs_write_resume(struct mount *mp, int flags)
 {
 
+	MPASS(vn_suspendable_mp(mp));
+
 	MNT_ILOCK(mp);
 	if ((mp->mnt_kern_flag & MNTK_SUSPEND) != 0) {
 		KASSERT(mp->mnt_susp_owner == curthread, ("mnt_susp_owner"));
@@ -1844,6 +1873,7 @@ vfs_write_suspend_umnt(struct mount *mp)
 {
 	int error;
 
+	MPASS(vn_suspendable_mp(mp));
 	KASSERT((curthread->td_pflags & TDP_IGNSUSP) == 0,
 	    ("vfs_write_suspend_umnt: recursed"));
 

Modified: head/sys/sys/mount.h
==============================================================================
--- head/sys/sys/mount.h	Sun Oct 19 04:38:02 2014	(r273270)
+++ head/sys/sys/mount.h	Sun Oct 19 06:59:33 2014	(r273271)
@@ -754,11 +754,10 @@ vfs_statfs_t	__vfs_statfs;
 	_rc; })
 
 #define	VFS_SUSP_CLEAN(MP) do {						\
-	if (*(MP)->mnt_op->vfs_susp_clean != NULL) {			\
-		VFS_PROLOGUE(MP);					\
-		(*(MP)->mnt_op->vfs_susp_clean)(MP);			\
-		VFS_EPILOGUE(MP);					\
-	}								\
+	MPASS(*(MP)->mnt_op->vfs_susp_clean != NULL); 			\
+	VFS_PROLOGUE(MP);						\
+	(*(MP)->mnt_op->vfs_susp_clean)(MP);				\
+	VFS_EPILOGUE(MP);						\
 } while (0)
 
 #define	VFS_RECLAIM_LOWERVP(MP, VP) do {				\



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