Module Name:    src
Committed By:   rmind
Date:           Mon Apr 18 15:53:04 UTC 2011

Modified Files:
        src/sys/miscfs/genfs: genfs_io.c
        src/sys/miscfs/syncfs: sync_subr.c syncfs.h
        src/sys/sys: vnode.h

Log Message:
G/C unused speedup_syncer() mechanism and thus simplify some code.
Update some comments to reflect the reality.  No actual changes to
the (used) syncer logic.

OK ad@


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/miscfs/genfs/genfs_io.c
cvs rdiff -u -r1.43 -r1.44 src/sys/miscfs/syncfs/sync_subr.c
cvs rdiff -u -r1.11 -r1.12 src/sys/miscfs/syncfs/syncfs.h
cvs rdiff -u -r1.227 -r1.228 src/sys/sys/vnode.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/miscfs/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.46 src/sys/miscfs/genfs/genfs_io.c:1.47
--- src/sys/miscfs/genfs/genfs_io.c:1.46	Mon Dec  6 10:22:43 2010
+++ src/sys/miscfs/genfs/genfs_io.c	Mon Apr 18 15:53:04 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.46 2010/12/06 10:22:43 uebayasi Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.47 2011/04/18 15:53:04 rmind Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.46 2010/12/06 10:22:43 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.47 2011/04/18 15:53:04 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -52,6 +52,7 @@
 #include <miscfs/genfs/genfs.h>
 #include <miscfs/genfs/genfs_node.h>
 #include <miscfs/specfs/specdev.h>
+#include <miscfs/syncfs/syncfs.h>
 
 #include <uvm/uvm.h>
 #include <uvm/uvm_pager.h>

Index: src/sys/miscfs/syncfs/sync_subr.c
diff -u src/sys/miscfs/syncfs/sync_subr.c:1.43 src/sys/miscfs/syncfs/sync_subr.c:1.44
--- src/sys/miscfs/syncfs/sync_subr.c:1.43	Wed Jul 21 17:52:12 2010
+++ src/sys/miscfs/syncfs/sync_subr.c	Mon Apr 18 15:53:04 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: sync_subr.c,v 1.43 2010/07/21 17:52:12 hannken Exp $	*/
+/*	$NetBSD: sync_subr.c,v 1.44 2011/04/18 15:53:04 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -60,8 +60,37 @@
  * SUCH DAMAGE.
  */
 
+/*
+ * The filesystem synchronizer mechanism - syncer.
+ *
+ * It is useful to delay writes of file data and filesystem metadata for
+ * a certain amount of time so that quickly created and deleted files need
+ * not waste disk bandwidth being created and removed.  To implement this,
+ * vnodes are appended to a "workitem" queue.
+ *
+ * Most pending metadata should not wait for more than ten seconds.  Thus,
+ * mounted on block devices are delayed only about a half the time that file
+ * data is delayed.  Similarly, directory updates are more critical, so are
+ * only delayed about a third the time that file data is delayed.
+ *
+ * There are SYNCER_MAXDELAY queues that are processed in a round-robin
+ * manner at a rate of one each second (driven off the filesystem syner
+ * thread). The syncer_delayno variable indicates the next queue that is
+ * to be processed.  Items that need to be processed soon are placed in
+ * this queue:
+ *
+ *	syncer_workitem_pending[syncer_delayno]
+ *
+ * A delay of e.g. fifteen seconds is done by placing the request fifteen
+ * entries later in the queue:
+ *
+ *	syncer_workitem_pending[(syncer_delayno + 15) & syncer_mask]
+ *
+ * Flag VI_ONWORKLST indicates that vnode is added into the queue.
+ */
+
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sync_subr.c,v 1.43 2010/07/21 17:52:12 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sync_subr.c,v 1.44 2011/04/18 15:53:04 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -78,7 +107,10 @@
 #include <miscfs/genfs/genfs.h>
 #include <miscfs/syncfs/syncfs.h>
 
+typedef TAILQ_HEAD(synclist, vnode) synclist_t;
+
 static void	vn_syncer_add1(struct vnode *, int);
+static void	sysctl_vfs_syncfs_setup(struct sysctllog **);
 
 /*
  * Defines and variables for the syncer process.
@@ -90,19 +122,12 @@
 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 structures */
+kmutex_t		syncer_mutex;	/* used to freeze syncer, long term */
+static kmutex_t		syncer_data_lock; /* short term lock on data structs */
 
-static int rushjob;			/* number of slots to run ASAP */
-static kcondvar_t syncer_cv;		/* cv for rushjob */
-static int stat_rush_requests;		/* number of times I/O speeded up */
-
-static int syncer_delayno = 0;
-static long syncer_last;
-static struct synclist *syncer_workitem_pending;
-struct lwp *updateproc = NULL;
-
-static void sysctl_vfs_syncfs_setup(struct sysctllog **);
+static int		syncer_delayno = 0;
+static long		syncer_last;
+static synclist_t *	syncer_workitem_pending;
 
 void
 vn_initialize_syncerd(void)
@@ -121,57 +146,27 @@
 
 	mutex_init(&syncer_mutex, MUTEX_DEFAULT, IPL_NONE);
 	mutex_init(&syncer_data_lock, MUTEX_DEFAULT, IPL_NONE);
-	cv_init(&syncer_cv, "syncer");
 }
 
 /*
- * The workitem queue.
- *
- * It is useful to delay writes of file data and filesystem metadata
- * for tens of seconds so that quickly created and deleted files need
- * not waste disk bandwidth being created and removed. To realize this,
- * we append vnodes to a "workitem" queue. When running with a soft
- * updates implementation, most pending metadata dependencies should
- * not wait for more than a few seconds. Thus, mounted on block devices
- * are delayed only about a half the time that file data is delayed.
- * Similarly, directory updates are more critical, so are only delayed
- * about a third the time that file data is delayed. Thus, there are
- * SYNCER_MAXDELAY queues that are processed round-robin at a rate of
- * one each second (driven off the filesystem syner process). The
- * syncer_delayno variable indicates the next queue that is to be processed.
- * Items that need to be processed soon are placed in this queue:
- *
- *	syncer_workitem_pending[syncer_delayno]
- *
- * A delay of fifteen seconds is done by placing the request fifteen
- * entries later in the queue:
- *
- *	syncer_workitem_pending[(syncer_delayno + 15) & syncer_mask]
- *
- */
-
-/*
  * Add an item to the syncer work queue.
  */
 static void
 vn_syncer_add1(struct vnode *vp, int delayx)
 {
-	struct synclist *slp;
+	synclist_t *slp;
 
 	KASSERT(mutex_owned(&syncer_data_lock));
 
 	if (vp->v_iflag & VI_ONWORKLST) {
+		/*
+		 * Remove in order to adjust the position of the vnode.
+		 * Note: called from sched_sync(), which will not hold
+		 * interlock, therefore we cannot modify v_iflag here.
+		 */
 		slp = &syncer_workitem_pending[vp->v_synclist_slot];
 		TAILQ_REMOVE(slp, vp, v_synclist);
 	} else {
-		/*
-		 * We must not modify v_iflag if the vnode
-		 * is already on a synclist: sched_sync()
-		 * calls this routine while holding only
-		 * syncer_data_lock in order to adjust the
-		 * position of the vnode.  syncer_data_lock
-		 * does not protect v_iflag.
-		 */
 		KASSERT(mutex_owned(&vp->v_interlock));
 		vp->v_iflag |= VI_ONWORKLST;
 	}
@@ -201,18 +196,16 @@
 void
 vn_syncer_remove_from_worklist(struct vnode *vp)
 {
-	struct synclist *slp;
+	synclist_t *slp;
 
 	KASSERT(mutex_owned(&vp->v_interlock));
 
 	mutex_enter(&syncer_data_lock);
-
 	if (vp->v_iflag & VI_ONWORKLST) {
 		vp->v_iflag &= ~VI_ONWORKLST;
 		slp = &syncer_workitem_pending[vp->v_synclist_slot];
 		TAILQ_REMOVE(slp, vp, v_synclist);
 	}
-
 	mutex_exit(&syncer_data_lock);
 }
 
@@ -220,15 +213,13 @@
  * System filesystem synchronizer daemon.
  */
 void
-sched_sync(void *v)
+sched_sync(void *arg)
 {
-	struct synclist *slp;
+	synclist_t *slp;
 	struct vnode *vp;
 	time_t starttime;
 	bool synced;
 
-	updateproc = curlwp;
-
 	for (;;) {
 		mutex_enter(&syncer_mutex);
 		mutex_enter(&syncer_data_lock);
@@ -292,66 +283,25 @@
 		mutex_exit(&syncer_mutex);
 
 		/*
-		 * Wait until there are more workitems to process.
+		 * If it has taken us less than a second to process the
+		 * current work, then wait.  Otherwise start right over
+		 * again.  We can still lose time if any single round
+		 * takes more than two seconds, but it does not really
+		 * matter as we are just trying to generally pace the
+		 * filesystem activity.
 		 */
-		if (rushjob > 0) {
-			/*
-			 * The variable rushjob allows the kernel to speed
-			 * up the processing of the filesystem syncer
-			 * process. A rushjob value of N tells the
-			 * filesystem syncer to process the next N seconds
-			 * worth of work on its queue ASAP. Currently
-			 * rushjob is used by the soft update code to
-			 * speed up the filesystem syncer process when the
-			 * incore state is getting so far ahead of the
-			 * disk that the kernel memory pool is being
-			 * threatened with exhaustion.
-			 */
-			rushjob--;
-		} else {
-			/*
-			 * If it has taken us less than a second to
-			 * process the current work, then wait. Otherwise
-			 * start right over again. We can still lose time
-			 * if any single round takes more than two
-			 * seconds, but it does not really matter as we
-			 * are just trying to generally pace the
-			 * filesystem activity.
-			 */
-			if (time_second == starttime)
-				cv_timedwait(&syncer_cv, &syncer_data_lock, hz);
+		if (time_second == starttime) {
+			kpause("syncer", false, hz, &syncer_data_lock);
 		}
 		mutex_exit(&syncer_data_lock);
 	}
 }
 
-/*
- * Request the syncer daemon to speed up its work.
- * We never push it to speed up more than half of its
- * normal turn time, otherwise it could take over the CPU.
- */
-int
-speedup_syncer(void)
-{
-
-	mutex_enter(&syncer_data_lock);
-	if (rushjob >= syncdelay / 2) {
-		mutex_exit(&syncer_data_lock);
-		return (0);
-	}
-	rushjob++;
-	cv_signal(&syncer_cv);
-	stat_rush_requests += 1;
-	mutex_exit(&syncer_data_lock);
-
-	return (1);
-}
-
 static void
 sysctl_vfs_syncfs_setup(struct sysctllog **clog)
 {
 	const struct sysctlnode *rnode, *cnode;
-        
+
 	sysctl_createv(clog, 0, NULL, &rnode,
 			CTLFLAG_PERMANENT,
 			CTLTYPE_NODE, "vfs", NULL,

Index: src/sys/miscfs/syncfs/syncfs.h
diff -u src/sys/miscfs/syncfs/syncfs.h:1.11 src/sys/miscfs/syncfs/syncfs.h:1.12
--- src/sys/miscfs/syncfs/syncfs.h:1.11	Fri Feb  9 21:55:36 2007
+++ src/sys/miscfs/syncfs/syncfs.h	Mon Apr 18 15:53:04 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: syncfs.h,v 1.11 2007/02/09 21:55:36 ad Exp $	*/
+/*	$NetBSD: syncfs.h,v 1.12 2011/04/18 15:53:04 rmind Exp $	*/
 
 /*
  * Copyright 1997 Marshall Kirk McKusick. All Rights Reserved.
@@ -47,17 +47,21 @@
 #define sync_islocked	genfs_noislocked
 #define sync_putpages	genfs_null_putpages
 
-void sched_sync(void *);
-void vn_initialize_syncerd(void);
-int vfs_allocate_syncvnode(struct mount *);
-void vfs_deallocate_syncvnode(struct mount *);
+void	sched_sync(void *);
+void	vn_initialize_syncerd(void);
+int	vfs_allocate_syncvnode(struct mount *);
+void	vfs_deallocate_syncvnode(struct mount *);
 
 extern int (**sync_vnodeop_p)(void *);
 
-#define SYNCER_MAXDELAY       32
+#define	SYNCER_MAXDELAY		32
 
-extern int syncer_maxdelay;	/* maximum delay time */
-extern kmutex_t syncer_mutex;	/* lock to freeze syncer during unmount */
-TAILQ_HEAD(synclist, vnode);
+extern int	syncer_maxdelay;
+extern kmutex_t	syncer_mutex;
+
+extern time_t	syncdelay;
+extern time_t	filedelay;
+extern time_t	dirdelay;
+extern time_t	metadelay;
 
 #endif /* _MISCFS_SYNCFS_SYNCFS_H_ */

Index: src/sys/sys/vnode.h
diff -u src/sys/sys/vnode.h:1.227 src/sys/sys/vnode.h:1.228
--- src/sys/sys/vnode.h:1.227	Sun Apr  3 01:19:36 2011
+++ src/sys/sys/vnode.h	Mon Apr 18 15:53:04 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnode.h,v 1.227 2011/04/03 01:19:36 rmind Exp $	*/
+/*	$NetBSD: vnode.h,v 1.228 2011/04/18 15:53:04 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -398,10 +398,6 @@
 extern struct vnode	*rootvnode;	/* root (i.e. "/") vnode */
 extern int		desiredvnodes;	/* number of vnodes desired */
 extern u_int		numvnodes;	/* current number of vnodes */
-extern time_t		syncdelay;	/* max time to delay syncing data */
-extern time_t		filedelay;	/* time to delay syncing files */
-extern time_t		dirdelay;	/* time to delay syncing directories */
-extern time_t		metadelay;	/* time to delay syncing metadata */
 
 /*
  * Macro/function to check for client cache inconsistency w.r.t. leasing.

Reply via email to