Source-Changes-HG archive

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

[src/trunk]: src/sys Remove the "target" argment from vfs_drainvnodes() as it is



details:   https://anonhg.NetBSD.org/src/rev/4676409e13c3
branches:  trunk
changeset: 819700:4676409e13c3
user:      hannken <hannken%NetBSD.org@localhost>
date:      Wed Dec 14 15:46:57 2016 +0000

description:
Remove the "target" argment from vfs_drainvnodes() as it is
always equal to "desiredvnodes" and move its definition
from sys/vnode.h to sys/vnode_impl.h.

Extend vfs_drainvnodes() to also wait for deferred vrele to flush
and replace the call to vrele_flush() with a call to vfs_drainvnodes().

diffstat:

 sys/kern/init_sysctl.c |   8 ++++----
 sys/kern/vfs_mount.c   |   8 ++++----
 sys/kern/vfs_vnode.c   |  38 ++++++++++++++++++--------------------
 sys/sys/vnode.h        |   4 +---
 sys/sys/vnode_impl.h   |   3 ++-
 5 files changed, 29 insertions(+), 32 deletions(-)

diffs (204 lines):

diff -r f453e8b972eb -r 4676409e13c3 sys/kern/init_sysctl.c
--- a/sys/kern/init_sysctl.c    Wed Dec 14 15:24:06 2016 +0000
+++ b/sys/kern/init_sysctl.c    Wed Dec 14 15:46:57 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init_sysctl.c,v 1.211 2016/05/31 05:44:19 pgoyette Exp $ */
+/*     $NetBSD: init_sysctl.c,v 1.212 2016/12/14 15:46:57 hannken Exp $ */
 
 /*-
  * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.211 2016/05/31 05:44:19 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.212 2016/12/14 15:46:57 hannken Exp $");
 
 #include "opt_sysv.h"
 #include "opt_compat_netbsd.h"
@@ -47,7 +47,7 @@
 #include <sys/unistd.h>
 #include <sys/disklabel.h>
 #include <sys/cprng.h>
-#include <sys/vnode.h>
+#include <sys/vnode_impl.h>    /* For vfs_drainvnodes(). */
 #include <sys/mount.h>
 #include <sys/namei.h>
 #include <dev/cons.h>
@@ -756,7 +756,7 @@
 
        old_vnodes = desiredvnodes;
        desiredvnodes = new_vnodes;
-       error = vfs_drainvnodes(new_vnodes);
+       error = vfs_drainvnodes();
        if (error) {
                desiredvnodes = old_vnodes;
                return (error);
diff -r f453e8b972eb -r 4676409e13c3 sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c      Wed Dec 14 15:24:06 2016 +0000
+++ b/sys/kern/vfs_mount.c      Wed Dec 14 15:46:57 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_mount.c,v 1.41 2016/11/03 11:03:31 hannken Exp $   */
+/*     $NetBSD: vfs_mount.c,v 1.42 2016/12/14 15:46:57 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.41 2016/11/03 11:03:31 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.42 2016/12/14 15:46:57 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -509,8 +509,8 @@
        int error, busy = 0, when = 0;
        struct vflush_ctx ctx;
 
-       /* First, flush out any vnode references from vrele_list. */
-       vrele_flush();
+       /* First, flush out any vnode references from deferred vrele list. */
+       vfs_drainvnodes();
 
        vfs_vnode_iterator_init(mp, &marker);
 
diff -r f453e8b972eb -r 4676409e13c3 sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c      Wed Dec 14 15:24:06 2016 +0000
+++ b/sys/kern/vfs_vnode.c      Wed Dec 14 15:46:57 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_vnode.c,v 1.60 2016/12/01 14:49:03 hannken Exp $   */
+/*     $NetBSD: vfs_vnode.c,v 1.61 2016/12/14 15:46:57 hannken Exp $   */
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -156,7 +156,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.60 2016/12/01 14:49:03 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.61 2016/12/14 15:46:57 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -208,6 +208,7 @@
 static struct {
        kmutex_t        lock;
        kcondvar_t      cv;
+       u_int           hashsize;
        u_long          hashmask;
        struct hashhead *hashtab;
        pool_cache_t    pool;
@@ -857,20 +858,6 @@
        }
 }
 
-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).
@@ -1040,6 +1027,7 @@
        KASSERT(vcache.pool != NULL);
        mutex_init(&vcache.lock, MUTEX_DEFAULT, IPL_NONE);
        cv_init(&vcache.cv, "vcache");
+       vcache.hashsize = desiredvnodes;
        vcache.hashtab = hashinit(desiredvnodes, HASH_SLIST, true,
            &vcache.hashmask);
 }
@@ -1057,6 +1045,7 @@
        mutex_enter(&vcache.lock);
        oldtab = vcache.hashtab;
        oldmask = vcache.hashmask;
+       vcache.hashsize = desiredvnodes;
        vcache.hashtab = newtab;
        vcache.hashmask = newmask;
        for (i = 0; i <= oldmask; i++) {
@@ -1601,13 +1590,21 @@
 }
 
 int
-vfs_drainvnodes(long target)
+vfs_drainvnodes(void)
 {
-       int error;
+       int error, 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);
 
        mutex_enter(&vnode_free_list_lock);
 
-       while (numvnodes > target) {
+       while (numvnodes > desiredvnodes) {
                error = cleanvnode();
                if (error != 0)
                        return error;
@@ -1616,7 +1613,8 @@
 
        mutex_exit(&vnode_free_list_lock);
 
-       vcache_reinit();
+       if (vcache.hashsize != desiredvnodes)
+               vcache_reinit();
 
        return 0;
 }
diff -r f453e8b972eb -r 4676409e13c3 sys/sys/vnode.h
--- a/sys/sys/vnode.h   Wed Dec 14 15:24:06 2016 +0000
+++ b/sys/sys/vnode.h   Wed Dec 14 15:46:57 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vnode.h,v 1.265 2016/11/03 11:03:31 hannken Exp $      */
+/*     $NetBSD: vnode.h,v 1.266 2016/12/14 15:46:57 hannken Exp $      */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -530,7 +530,6 @@
 bool   vrecycle(struct vnode *);
 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 *);
 int    vdead_check(struct vnode *, int);
@@ -581,7 +580,6 @@
 
 /* see vfssubr(9) */
 void   vfs_getnewfsid(struct mount *);
-int    vfs_drainvnodes(long);
 void   vfs_timestamp(struct timespec *);
 #if defined(DDB) || defined(DEBUGPRINT)
 void   vfs_vnode_print(struct vnode *, int, void (*)(const char *, ...)
diff -r f453e8b972eb -r 4676409e13c3 sys/sys/vnode_impl.h
--- a/sys/sys/vnode_impl.h      Wed Dec 14 15:24:06 2016 +0000
+++ b/sys/sys/vnode_impl.h      Wed Dec 14 15:46:57 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vnode_impl.h,v 1.2 2016/11/03 11:04:21 hannken Exp $   */
+/*     $NetBSD: vnode_impl.h,v 1.3 2016/12/14 15:46:57 hannken Exp $   */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -67,5 +67,6 @@
        vnalloc_marker(struct mount *);
 void   vnfree_marker(vnode_t *);
 bool   vnis_marker(vnode_t *);
+int    vfs_drainvnodes(void);
 
 #endif /* !_SYS_VNODE_IMPL_H_ */



Home | Main Index | Thread Index | Old Index