Module Name:    src
Committed By:   hannken
Date:           Wed May 24 09:53:00 UTC 2017

Modified Files:
        src/sys/kern: vfs_mount.c vfs_subr.c
        src/sys/sys: mount.h

Log Message:
Remove the syncer dance from dounmount().  The syncer skips
unmounting file systems as they are suspended.

Remove now unused syncer_mutex.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.464 -r1.465 src/sys/kern/vfs_subr.c
cvs rdiff -u -r1.226 -r1.227 src/sys/sys/mount.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.62 src/sys/kern/vfs_mount.c:1.63
--- src/sys/kern/vfs_mount.c:1.62	Wed May 17 12:45:03 2017
+++ src/sys/kern/vfs_mount.c	Wed May 24 09:52:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.62 2017/05/17 12:45:03 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.63 2017/05/24 09:52:59 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.62 2017/05/17 12:45:03 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.63 2017/05/24 09:52:59 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -869,15 +869,8 @@ dounmount(struct mount *mp, int flags, s
 	}
 	mountlist_iterator_destroy(iter);
 
-	/*
-	 * XXX Freeze syncer.  Must do this before locking the
-	 * mount point.  See dounmount() for details.
-	 */
-	mutex_enter(&syncer_mutex);
-
 	error = vfs_suspend(mp, 0);
 	if (error) {
-		mutex_exit(&syncer_mutex);
 		return error;
 	}
 
@@ -887,7 +880,6 @@ dounmount(struct mount *mp, int flags, s
 	mutex_enter(&mp->mnt_unmounting);
 	if (mp->mnt_busynest != 0) {
 		mutex_exit(&mp->mnt_unmounting);
-		mutex_exit(&syncer_mutex);
 		vfs_resume(mp);
 		return EBUSY;
 	}
@@ -897,28 +889,12 @@ dounmount(struct mount *mp, int flags, s
 	 */
 	if ((mp->mnt_iflag & IMNT_GONE) != 0) {
 		mutex_exit(&mp->mnt_unmounting);
-		mutex_exit(&syncer_mutex);
 		return ENOENT;
 	}
 
 	used_syncer = (mp->mnt_iflag & IMNT_ONWORKLIST) != 0;
 	used_extattr = mp->mnt_flag & MNT_EXTATTR;
 
-	/*
-	 * XXX Syncer must be frozen when we get here.  This should really
-	 * be done on a per-mountpoint basis, but the syncer doesn't work
-	 * like that.
-	 *
-	 * The caller of dounmount() must acquire syncer_mutex because
-	 * the syncer itself acquires locks in syncer_mutex -> vfs_busy
-	 * order, and we must preserve that order to avoid deadlock.
-	 *
-	 * So, if the file system did not use the syncer, now is
-	 * the time to release the syncer_mutex.
-	 */
-	if (used_syncer == 0) {
-		mutex_exit(&syncer_mutex);
-	}
 	mp->mnt_iflag |= IMNT_UNMOUNT;
 	mutex_enter(&mp->mnt_updating);
 	async = mp->mnt_flag & MNT_ASYNC;
@@ -941,8 +917,6 @@ dounmount(struct mount *mp, int flags, s
 		mp->mnt_flag |= async;
 		mutex_exit(&mp->mnt_updating);
 		vfs_resume(mp);
-		if (used_syncer)
-			mutex_exit(&syncer_mutex);
 		if (used_extattr) {
 			if (start_extattr(mp) != 0)
 				mp->mnt_flag &= ~MNT_EXTATTR;
@@ -973,8 +947,6 @@ dounmount(struct mount *mp, int flags, s
 	mountlist_remove(mp);
 	if (TAILQ_FIRST(&mp->mnt_vnodelist) != NULL)
 		panic("unmount: dangling vnode");
-	if (used_syncer)
-		mutex_exit(&syncer_mutex);
 	vfs_hooks_unmount(mp);
 
 	fstrans_unmount(mp);

Index: src/sys/kern/vfs_subr.c
diff -u src/sys/kern/vfs_subr.c:1.464 src/sys/kern/vfs_subr.c:1.465
--- src/sys/kern/vfs_subr.c:1.464	Sun May  7 08:26:58 2017
+++ src/sys/kern/vfs_subr.c	Wed May 24 09:52:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_subr.c,v 1.464 2017/05/07 08:26:58 hannken Exp $	*/
+/*	$NetBSD: vfs_subr.c,v 1.465 2017/05/24 09:52:59 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.464 2017/05/07 08:26:58 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.465 2017/05/24 09:52:59 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -568,7 +568,6 @@ time_t dirdelay  = 15;			/* time to dela
 time_t metadelay = 10;			/* time to delay syncing metadata */
 time_t lockdelay = 1;			/* time to delay if locking fails */
 
-kmutex_t		syncer_mutex;	/* used to freeze syncer, long term */
 static kmutex_t		syncer_data_lock; /* short term lock on data structs */
 
 static int		syncer_delayno = 0;
@@ -590,7 +589,6 @@ vn_initialize_syncerd(void)
 	for (i = 0; i < syncer_last; i++)
 		TAILQ_INIT(&syncer_workitem_pending[i]);
 
-	mutex_init(&syncer_mutex, MUTEX_DEFAULT, IPL_NONE);
 	mutex_init(&syncer_data_lock, MUTEX_DEFAULT, IPL_NONE);
 }
 
@@ -767,8 +765,6 @@ sched_sync(void *arg)
 	bool synced;
 
 	for (;;) {
-		mutex_enter(&syncer_mutex);
-
 		starttime = time_second;
 
 		/*
@@ -830,7 +826,6 @@ sched_sync(void *arg)
 				    synced ? syncdelay : lockdelay);
 			}
 		}
-		mutex_exit(&syncer_mutex);
 
 		/*
 		 * If it has taken us less than a second to process the

Index: src/sys/sys/mount.h
diff -u src/sys/sys/mount.h:1.226 src/sys/sys/mount.h:1.227
--- src/sys/sys/mount.h:1.226	Mon Apr 17 08:34:27 2017
+++ src/sys/sys/mount.h	Wed May 24 09:52:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mount.h,v 1.226 2017/04/17 08:34:27 hannken Exp $	*/
+/*	$NetBSD: mount.h,v 1.227 2017/05/24 09:52:59 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993
@@ -458,7 +458,6 @@ struct vnode *vfs_vnode_iterator_next(st
 
 /* Syncer */
 extern int	syncer_maxdelay;
-extern kmutex_t	syncer_mutex;
 extern time_t	syncdelay;
 extern time_t	filedelay;
 extern time_t	dirdelay;

Reply via email to