Module Name:    src
Committed By:   rmind
Date:           Sat Apr  2 04:45:25 UTC 2011

Modified Files:
        src/sys/kern: vfs_mount.c vfs_vnode.c
        src/sys/sys: vnode.h

Log Message:
- Move vrele_list flush notify code into vrele_flush() routine.
- Make some structures static.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/kern/vfs_mount.c src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.224 -r1.225 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/kern/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.1 src/sys/kern/vfs_mount.c:1.2
--- src/sys/kern/vfs_mount.c:1.1	Sat Apr  2 04:28:56 2011
+++ src/sys/kern/vfs_mount.c	Sat Apr  2 04:45:24 2011
@@ -1,7 +1,7 @@
-/*	$NetBSD: vfs_mount.c,v 1.1 2011/04/02 04:28:56 rmind Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.2 2011/04/02 04:45:24 rmind Exp $	*/
 
 /*-
- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
+ * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.1 2011/04/02 04:28:56 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.2 2011/04/02 04:45:24 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -436,31 +436,20 @@
 	return vunmark(mvp);
 }
 
-extern kmutex_t	vrele_lock;
-extern kcondvar_t vrele_cv;
-extern int vrele_pending;
-extern int vrele_gen;
-
 int
 vflush(struct mount *mp, vnode_t *skipvp, int flags)
 {
 	vnode_t *vp, *mvp;
-	int busy = 0, when = 0, gen;
+	int busy = 0, when = 0;
 
-	/*
-	 * First, flush out any vnode references from vrele_list.
-	 */
-	mutex_enter(&vrele_lock);
-	gen = vrele_gen;
-	while (vrele_pending && gen == vrele_gen) {
-		cv_broadcast(&vrele_cv);
-		cv_wait(&vrele_cv, &vrele_lock);
-	}
-	mutex_exit(&vrele_lock);
+	/* First, flush out any vnode references from vrele_list. */
+	vrele_flush();
 
 	/* Allocate a marker vnode. */
-	if ((mvp = vnalloc(mp)) == NULL)
-		return (ENOMEM);
+	mvp = vnalloc(mp);
+	if (mvp == NULL) {
+		return ENOMEM;
+	}
 
 	/*
 	 * NOTE: not using the TAILQ_FOREACH here since in this loop vgone()
Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.1 src/sys/kern/vfs_vnode.c:1.2
--- src/sys/kern/vfs_vnode.c:1.1	Sat Apr  2 04:28:57 2011
+++ src/sys/kern/vfs_vnode.c	Sat Apr  2 04:45:24 2011
@@ -1,7 +1,7 @@
-/*	$NetBSD: vfs_vnode.c,v 1.1 2011/04/02 04:28:57 rmind Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.2 2011/04/02 04:45:24 rmind Exp $	*/
 
 /*-
- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
+ * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.1 2011/04/02 04:28:57 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.2 2011/04/02 04:45:24 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -124,11 +124,11 @@
 static vnodelst_t	vnode_hold_list;
 static vnodelst_t	vrele_list;
 
-/* static */ kmutex_t	vrele_lock;
-/* static */ kcondvar_t	vrele_cv;
+static kmutex_t		vrele_lock;
+static kcondvar_t	vrele_cv;
 static lwp_t *		vrele_lwp;
-/* static */ int	vrele_pending;
-/* static */ int	vrele_gen;
+static int		vrele_pending;
+static int		vrele_gen;
 
 static vnode_t *	getcleanvnode(void);
 static void		vrele_thread(void *);
@@ -840,6 +840,20 @@
 	}
 }
 
+void
+vrele_flush(void)
+{
+	int gen;
+
+	mutex_enter(&vrele_lock);
+	gen = vrele_gen;
+	while (vrele_pending && gen == vrele_gen) {
+		cv_broadcast(&vrele_cv);
+		cv_wait(&vrele_cv, &vrele_lock);
+	}
+	mutex_exit(&vrele_lock);
+}
+
 /*
  * Vnode reference, where a reference is already held by some other
  * object (for example, a file structure).

Index: src/sys/sys/vnode.h
diff -u src/sys/sys/vnode.h:1.224 src/sys/sys/vnode.h:1.225
--- src/sys/sys/vnode.h:1.224	Sat Apr  2 04:28:57 2011
+++ src/sys/sys/vnode.h	Sat Apr  2 04:45:24 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnode.h,v 1.224 2011/04/02 04:28:57 rmind Exp $	*/
+/*	$NetBSD: vnode.h,v 1.225 2011/04/02 04:45:24 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -581,6 +581,7 @@
 int	vrecycle(struct vnode *, kmutex_t *, struct lwp *);
 void 	vrele(struct vnode *);
 void 	vrele_async(struct vnode *);
+void	vrele_flush(void);
 int	vtruncbuf(struct vnode *, daddr_t, bool, int);
 void	vwakeup(struct buf *);
 void	vwait(struct vnode *, int);

Reply via email to