Source-Changes-HG archive

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

[src/trunk]: src Rename vget() to vcache_vget() and vcache_tryvget() respecti...



details:   https://anonhg.NetBSD.org/src/rev/af7843d7cea9
branches:  trunk
changeset: 820165:af7843d7cea9
user:      hannken <hannken%NetBSD.org@localhost>
date:      Mon Jan 02 10:33:28 2017 +0000

description:
Rename vget() to vcache_vget() and vcache_tryvget() respectively and
move the definitions to sys/vnode_impl.h.

No functional change intended.

Welcome to 7.99.54

diffstat:

 distrib/sets/lists/comp/mi     |    8 +-
 share/man/man9/Makefile        |    3 +-
 share/man/man9/vnode.9         |   78 +------------------
 share/man/man9/vnsubr.9        |    5 +-
 sys/kern/vfs_cache.c           |   20 ++--
 sys/kern/vfs_mount.c           |    8 +-
 sys/kern/vfs_subr.c            |    6 +-
 sys/kern/vfs_vnode.c           |  160 ++++++++++++++++++++++++----------------
 sys/miscfs/specfs/spec_vnops.c |   10 +-
 sys/sys/param.h                |    4 +-
 sys/sys/vnode.h                |    3 +-
 sys/sys/vnode_impl.h           |    4 +-
 12 files changed, 137 insertions(+), 172 deletions(-)

diffs (truncated from 656 to 300 lines):

diff -r c47464d1a770 -r af7843d7cea9 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Mon Jan 02 10:28:34 2017 +0000
+++ b/distrib/sets/lists/comp/mi        Mon Jan 02 10:33:28 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: mi,v 1.2089 2017/01/02 10:28:35 roy Exp $
+#      $NetBSD: mi,v 1.2090 2017/01/02 10:33:28 hannken Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.comp                           comp-sys-root
@@ -11234,7 +11234,7 @@
 ./usr/share/man/cat9/vfs_write_suspend.0       comp-obsolete           obsolete
 ./usr/share/man/cat9/vfsops.0                  comp-sys-catman         .cat
 ./usr/share/man/cat9/vfssubr.0                 comp-sys-catman         .cat
-./usr/share/man/cat9/vget.0                    comp-sys-catman         .cat
+./usr/share/man/cat9/vget.0                    comp-sys-catman         obsolete
 ./usr/share/man/cat9/vgone.0                   comp-sys-catman         .cat
 ./usr/share/man/cat9/vgonel.0                  comp-sys-catman         .cat
 ./usr/share/man/cat9/vhold.0                   comp-sys-catman         .cat
@@ -18418,7 +18418,7 @@
 ./usr/share/man/html9/vfs_vnode_iterator_next.html     comp-sys-htmlman        html
 ./usr/share/man/html9/vfsops.html              comp-sys-htmlman        html
 ./usr/share/man/html9/vfssubr.html             comp-sys-htmlman        html
-./usr/share/man/html9/vget.html                        comp-sys-htmlman        html
+./usr/share/man/html9/vget.html                        comp-sys-htmlman        obsolete
 ./usr/share/man/html9/vgone.html               comp-sys-htmlman        html
 ./usr/share/man/html9/vgonel.html              comp-sys-htmlman        html
 ./usr/share/man/html9/vhold.html               comp-sys-htmlman        html
@@ -25842,7 +25842,7 @@
 ./usr/share/man/man9/vfs_write_suspend.9       comp-obsolete           obsolete
 ./usr/share/man/man9/vfsops.9                  comp-sys-man            .man
 ./usr/share/man/man9/vfssubr.9                 comp-sys-man            .man
-./usr/share/man/man9/vget.9                    comp-sys-man            .man
+./usr/share/man/man9/vget.9                    comp-sys-man            obsolete
 ./usr/share/man/man9/vgone.9                   comp-sys-man            .man
 ./usr/share/man/man9/vgonel.9                  comp-sys-man            .man
 ./usr/share/man/man9/vhold.9                   comp-sys-man            .man
diff -r c47464d1a770 -r af7843d7cea9 share/man/man9/Makefile
--- a/share/man/man9/Makefile   Mon Jan 02 10:28:34 2017 +0000
+++ b/share/man/man9/Makefile   Mon Jan 02 10:33:28 2017 +0000
@@ -1,4 +1,4 @@
-#       $NetBSD: Makefile,v 1.399 2016/12/22 11:46:48 cherry Exp $
+#       $NetBSD: Makefile,v 1.400 2017/01/02 10:33:28 hannken Exp $
 
 #      Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -949,7 +949,6 @@
 MLINKS+=vnode.9 vref.9 \
        vnode.9 vrele.9 \
        vnode.9 vrele_async.9 \
-       vnode.9 vget.9 \
        vnode.9 vput.9 \
        vnode.9 vhold.9 \
        vnode.9 holdrele.9 \
diff -r c47464d1a770 -r af7843d7cea9 share/man/man9/vnode.9
--- a/share/man/man9/vnode.9    Mon Jan 02 10:28:34 2017 +0000
+++ b/share/man/man9/vnode.9    Mon Jan 02 10:33:28 2017 +0000
@@ -1,4 +1,4 @@
-.\"     $NetBSD: vnode.9,v 1.73 2016/12/14 15:48:54 hannken Exp $
+.\"     $NetBSD: vnode.9,v 1.74 2017/01/02 10:33:28 hannken Exp $
 .\"
 .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 14, 2016
+.Dd January 2, 2017
 .Dt VNODE 9
 .Os
 .Sh NAME
@@ -35,7 +35,6 @@
 .Nm vref ,
 .Nm vrele ,
 .Nm vrele_async ,
-.Nm vget ,
 .Nm vput ,
 .Nm vhold ,
 .Nm holdrele ,
@@ -68,8 +67,6 @@
 .Fn vrele "struct vnode *vp"
 .Ft void
 .Fn vrele_async "struct vnode *vp"
-.Ft int
-.Fn vget "struct vnode *vp" "int lockflag" "int wait"
 .Ft void
 .Fn vput "struct vnode *vp"
 .Ft void
@@ -152,12 +149,10 @@
 have any users, and another thread in the system may be simultaneously
 deciding to reclaim it.
 Thus, to retrieve a vnode from a cache, one must use
-.Fn vget ,
+.Fn vcache_get ,
 not
 .Fn vref ,
-to acquire the first reference, and be prepared for
-.Fn vget
-to fail if another thread is reclaiming the vnode.
+to acquire the first reference.
 .Pp
 The vnode has the following structure:
 .Bd -literal
@@ -349,10 +344,8 @@
 .Xr vnodeops 9
 for a description of vnode operations.
 .Pp
-When a valid vnode which is cached is used again, the user must call
-.Fn vget
-to increment the reference count.
-When a user wants a new vnode for another file,
+When a user wants a new vnode for another file or wants a valid vnode
+which is cached,
 .Fn vcache_get
 or
 .Fn vcache_new
@@ -540,60 +533,6 @@
 .It Fn vrele_async "vp"
 Will asychronously release the vnode in different context than the caller,
 sometime after the call.
-.It Fn vget "vp" "lockflags" "wait"
-Reclaim vnode
-.Fa vp
-from the cache and increment its reference count.
-.Pp
-The vnode
-.Fa vp
-may be changing state: another thread may be initializing it from disk,
-or revoking it with
-.Xr revoke 2 ,
-or reclaiming it with
-.Xr VOP_RECLAIM 9 .
-In that case,
-.Fn vget
-will wait until the state has changed, if
-.Fa lockflags
-is
-.Li 0
-and
-.Fa wait
-is
-.Li true ;
-or will return
-.Er EBUSY
-if
-.Fa lockflags
-is
-.Dv LK_NOWAIT
-and
-.Fa wait
-is
-.Li false .
-.Pp
-(The extra argument enables the compiler to detect old code which
-additionally used
-.Fn vget
-to lock the vnode.)
-.Pp
-Returns
-.Bl -tag -offset abcd -width ENOENT -compact
-.It Er EBUSY
-if
-.Fa vp
-was changing state and
-.Fa wait
-is false.
-.It Er ENOENT
-if the system was reclaiming
-.Fa vp
-with
-.Xr VOP_RECLAIM 9 .
-.It Li 0
-on success.
-.El
 .It Fn vput "vp"
 Legacy convenience routine for unlocking and releasing
 .Fa vp .
@@ -603,11 +542,6 @@
 .No "vrele(" Ns Fa vp Ns Li ");"
 .Ed
 .Pp
-Note that this is
-.Em not
-an inverse of
-.Fn vget .
-The name appears so for hysterical raisins.
 New code should prefer using
 .Xr VOP_UNLOCK 9
 and
diff -r c47464d1a770 -r af7843d7cea9 share/man/man9/vnsubr.9
--- a/share/man/man9/vnsubr.9   Mon Jan 02 10:28:34 2017 +0000
+++ b/share/man/man9/vnsubr.9   Mon Jan 02 10:33:28 2017 +0000
@@ -1,4 +1,4 @@
-.\"     $NetBSD: vnsubr.9,v 1.43 2015/07/11 15:42:31 wiz Exp $
+.\"     $NetBSD: vnsubr.9,v 1.44 2017/01/02 10:33:28 hannken Exp $
 .\"
 .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -146,9 +146,6 @@
 .Pp
 .Fn vn_lock
 must not be called when the vnode's reference count is zero.
-Instead,
-.Xr vget 9
-should be used.
 .It Fn vn_markexec "vp"
 Common code to mark the vnode
 .Fa vp
diff -r c47464d1a770 -r af7843d7cea9 sys/kern/vfs_cache.c
--- a/sys/kern/vfs_cache.c      Mon Jan 02 10:28:34 2017 +0000
+++ b/sys/kern/vfs_cache.c      Mon Jan 02 10:33:28 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_cache.c,v 1.110 2016/07/07 06:55:43 msaitoh Exp $  */
+/*     $NetBSD: vfs_cache.c,v 1.111 2017/01/02 10:33:28 hannken Exp $  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.110 2016/07/07 06:55:43 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.111 2017/01/02 10:33:28 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -71,7 +71,7 @@
 #include <sys/sysctl.h>
 #include <sys/time.h>
 #include <sys/mount.h>
-#include <sys/vnode.h>
+#include <sys/vnode_impl.h>
 #include <sys/namei.h>
 #include <sys/errno.h>
 #include <sys/pool.h>
@@ -101,8 +101,8 @@
  * is for DELETE, or NOCACHE is set (rewrite), and the
  * name is located in the cache, it will be dropped.
  * The entry is dropped also when it was not possible to lock
- * the cached vnode, either because vget() failed or the generation
- * number has changed while waiting for the lock.
+ * the cached vnode, either because vcache_tryvget() failed or
+ * the generation number has changed while waiting for the lock.
  */
 
 /*
@@ -588,9 +588,9 @@
        mutex_exit(&cpup->cpu_lock);
 
        /*
-        * Unlocked except for the vnode interlock.  Call vget().
+        * Unlocked except for the vnode interlock.  Call vcache_tryvget().
         */
-       error = vget(vp, LK_NOWAIT, false /* !wait */);
+       error = vcache_tryvget(vp);
        if (error) {
                KASSERT(error == EBUSY);
                /*
@@ -669,9 +669,9 @@
        mutex_exit(&cpup->cpu_lock);
 
        /*
-        * Unlocked except for the vnode interlock.  Call vget().
+        * Unlocked except for the vnode interlock.  Call vcache_tryvget().
         */
-       error = vget(vp, LK_NOWAIT, false /* !wait */);
+       error = vcache_tryvget(vp);
        if (error) {
                KASSERT(error == EBUSY);
                /*
@@ -761,7 +761,7 @@
                        mutex_enter(dvp->v_interlock);
                        mutex_exit(&ncp->nc_lock);
                        mutex_exit(namecache_lock);
-                       error = vget(dvp, LK_NOWAIT, false /* !wait */);
+                       error = vcache_tryvget(dvp);
                        if (error) {
                                KASSERT(error == EBUSY);
                                if (bufp)
diff -r c47464d1a770 -r af7843d7cea9 sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c      Mon Jan 02 10:28:34 2017 +0000
+++ b/sys/kern/vfs_mount.c      Mon Jan 02 10:33:28 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_mount.c,v 1.42 2016/12/14 15:46:57 hannken Exp $   */
+/*     $NetBSD: vfs_mount.c,v 1.43 2017/01/02 10:33:28 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.42 2016/12/14 15:46:57 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.43 2017/01/02 10:33:28 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -402,7 +402,7 @@
                TAILQ_INSERT_AFTER(&mp->mnt_vnodelist, vp, mvp, v_mntvnodes);
                mvp->v_usecount = 1;



Home | Main Index | Thread Index | Old Index