Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys - Move vrele_list flush notify code into vrele_flush() r...



details:   https://anonhg.NetBSD.org/src/rev/b9e62c30f24e
branches:  trunk
changeset: 763734:b9e62c30f24e
user:      rmind <rmind%NetBSD.org@localhost>
date:      Sat Apr 02 04:45:24 2011 +0000

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

diffstat:

 sys/kern/vfs_mount.c |  31 ++++++++++---------------------
 sys/kern/vfs_vnode.c |  28 +++++++++++++++++++++-------
 sys/sys/vnode.h      |   3 ++-
 3 files changed, 33 insertions(+), 29 deletions(-)

diffs (137 lines):

diff -r 473326fbf3ad -r b9e62c30f24e sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c      Sat Apr 02 04:28:56 2011 +0000
+++ b/sys/kern/vfs_mount.c      Sat Apr 02 04:45:24 2011 +0000
@@ -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()
diff -r 473326fbf3ad -r b9e62c30f24e sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c      Sat Apr 02 04:28:56 2011 +0000
+++ b/sys/kern/vfs_vnode.c      Sat Apr 02 04:45:24 2011 +0000
@@ -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).
diff -r 473326fbf3ad -r b9e62c30f24e sys/sys/vnode.h
--- a/sys/sys/vnode.h   Sat Apr 02 04:28:56 2011 +0000
+++ b/sys/sys/vnode.h   Sat Apr 02 04:45:24 2011 +0000
@@ -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);



Home | Main Index | Thread Index | Old Index