Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Prepare the split of sys/vnode.h into sys/vnode.h a...



details:   https://anonhg.NetBSD.org/src/rev/322954a041bb
branches:  trunk
changeset: 818849:322954a041bb
user:      hannken <hannken%NetBSD.org@localhost>
date:      Thu Nov 03 11:02:09 2016 +0000

description:
Prepare the split of sys/vnode.h into sys/vnode.h and sys/vnode_impl.h
- Rename struct vcache_node to vnode_impl, start its fields with vi_.
- Rename enum vcache_state to vnode_state, start its elements with VS_.
- Rename macros VN_TO_VP and VP_TO_VN to VIMPL_TO_VNODE and VNODE_TO_VIMPL.
- Add typedef struct vnode_impl vnode_impl_t.

diffstat:

 sys/kern/vfs_vnode.c |  327 +++++++++++++++++++++++++-------------------------
 1 files changed, 164 insertions(+), 163 deletions(-)

diffs (truncated from 875 to 300 lines):

diff -r 151edcc47ee6 -r 322954a041bb sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c      Thu Nov 03 10:11:05 2016 +0000
+++ b/sys/kern/vfs_vnode.c      Thu Nov 03 11:02:09 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_vnode.c,v 1.56 2016/08/20 12:37:08 hannken Exp $   */
+/*     $NetBSD: vfs_vnode.c,v 1.57 2016/11/03 11:02:09 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.56 2016/08/20 12:37:08 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.57 2016/11/03 11:02:09 hannken Exp $");
 
 #define _VFS_VNODE_PRIVATE
 
@@ -187,28 +187,29 @@
 /* Flags to vrelel. */
 #define        VRELEL_ASYNC_RELE       0x0001  /* Always defer to vrele thread. */
 
-enum vcache_state {
-       VN_MARKER,      /* Stable, used as marker. Will not change. */
-       VN_LOADING,     /* Intermediate, initialising the fs node. */
-       VN_ACTIVE,      /* Stable, valid fs node attached. */
-       VN_BLOCKED,     /* Intermediate, active, no new references allowed. */
-       VN_RECLAIMING,  /* Intermediate, detaching the fs node. */
-       VN_RECLAIMED    /* Stable, no fs node attached. */
+enum vnode_state {
+       VS_MARKER,      /* Stable, used as marker. Will not change. */
+       VS_LOADING,     /* Intermediate, initialising the fs node. */
+       VS_ACTIVE,      /* Stable, valid fs node attached. */
+       VS_BLOCKED,     /* Intermediate, active, no new references allowed. */
+       VS_RECLAIMING,  /* Intermediate, detaching the fs node. */
+       VS_RECLAIMED    /* Stable, no fs node attached. */
 };
 struct vcache_key {
        struct mount *vk_mount;
        const void *vk_key;
        size_t vk_key_len;
 };
-struct vcache_node {
-       struct vnode vn_vnode;
-       enum vcache_state vn_state;
-       SLIST_ENTRY(vcache_node) vn_hash;
-       struct vcache_key vn_key;
+struct vnode_impl {
+       struct vnode vi_vnode;
+       enum vnode_state vi_state;
+       SLIST_ENTRY(vnode_impl) vi_hash;
+       struct vcache_key vi_key;
 };
+typedef struct vnode_impl vnode_impl_t;
 
-#define VN_TO_VP(node) ((vnode_t *)(node))
-#define VP_TO_VN(vp)   ((struct vcache_node *)(vp))
+#define VIMPL_TO_VNODE(node)   ((vnode_t *)(node))
+#define VNODE_TO_VIMPL(vp)     ((vnode_impl_t *)(vp))
 
 u_int                  numvnodes               __cacheline_aligned;
 
@@ -229,7 +230,7 @@
 static int             vrele_pending           __cacheline_aligned;
 static int             vrele_gen               __cacheline_aligned;
 
-SLIST_HEAD(hashhead, vcache_node);
+SLIST_HEAD(hashhead, vnode_impl);
 static struct {
        kmutex_t        lock;
        kcondvar_t      cv;
@@ -239,8 +240,8 @@
 }                      vcache                  __cacheline_aligned;
 
 static int             cleanvnode(void);
-static struct vcache_node *vcache_alloc(void);
-static void            vcache_free(struct vcache_node *);
+static vnode_impl_t *vcache_alloc(void);
+static void            vcache_free(vnode_impl_t *);
 static void            vcache_init(void);
 static void            vcache_reinit(void);
 static void            vcache_reclaim(vnode_t *);
@@ -258,21 +259,21 @@
 /* Vnode state operations and diagnostics. */
 
 static const char *
-vstate_name(enum vcache_state state)
+vstate_name(enum vnode_state state)
 {
 
        switch (state) {
-       case VN_MARKER:
+       case VS_MARKER:
                return "MARKER";
-       case VN_LOADING:
+       case VS_LOADING:
                return "LOADING";
-       case VN_ACTIVE:
+       case VS_ACTIVE:
                return "ACTIVE";
-       case VN_BLOCKED:
+       case VS_BLOCKED:
                return "BLOCKED";
-       case VN_RECLAIMING:
+       case VS_RECLAIMING:
                return "RECLAIMING";
-       case VN_RECLAIMED:
+       case VS_RECLAIMED:
                return "RECLAIMED";
        default:
                return "ILLEGAL";
@@ -291,80 +292,80 @@
        vstate_assert((vp), (state), __func__, __LINE__)
 
 static void
-vstate_assert(vnode_t *vp, enum vcache_state state, const char *func, int line)
+vstate_assert(vnode_t *vp, enum vnode_state state, const char *func, int line)
 {
-       struct vcache_node *node = VP_TO_VN(vp);
+       vnode_impl_t *node = VNODE_TO_VIMPL(vp);
 
        KASSERTMSG(mutex_owned(vp->v_interlock), "at %s:%d", func, line);
 
-       if (__predict_true(node->vn_state == state))
+       if (__predict_true(node->vi_state == state))
                return;
        vnpanic(vp, "state is %s, expected %s at %s:%d",
-           vstate_name(node->vn_state), vstate_name(state), func, line);
+           vstate_name(node->vi_state), vstate_name(state), func, line);
 }
 
-static enum vcache_state
+static enum vnode_state
 vstate_assert_get(vnode_t *vp, const char *func, int line)
 {
-       struct vcache_node *node = VP_TO_VN(vp);
+       vnode_impl_t *node = VNODE_TO_VIMPL(vp);
 
        KASSERTMSG(mutex_owned(vp->v_interlock), "at %s:%d", func, line);
-       if (node->vn_state == VN_MARKER)
+       if (node->vi_state == VS_MARKER)
                vnpanic(vp, "state is %s at %s:%d",
-                   vstate_name(node->vn_state), func, line);
+                   vstate_name(node->vi_state), func, line);
 
-       return node->vn_state;
+       return node->vi_state;
 }
 
 static void
 vstate_assert_wait_stable(vnode_t *vp, const char *func, int line)
 {
-       struct vcache_node *node = VP_TO_VN(vp);
+       vnode_impl_t *node = VNODE_TO_VIMPL(vp);
 
        KASSERTMSG(mutex_owned(vp->v_interlock), "at %s:%d", func, line);
-       if (node->vn_state == VN_MARKER)
+       if (node->vi_state == VS_MARKER)
                vnpanic(vp, "state is %s at %s:%d",
-                   vstate_name(node->vn_state), func, line);
+                   vstate_name(node->vi_state), func, line);
 
-       while (node->vn_state != VN_ACTIVE && node->vn_state != VN_RECLAIMED)
+       while (node->vi_state != VS_ACTIVE && node->vi_state != VS_RECLAIMED)
                cv_wait(&vp->v_cv, vp->v_interlock);
 
-       if (node->vn_state == VN_MARKER)
+       if (node->vi_state == VS_MARKER)
                vnpanic(vp, "state is %s at %s:%d",
-                   vstate_name(node->vn_state), func, line);
+                   vstate_name(node->vi_state), func, line);
 }
 
 static void
-vstate_assert_change(vnode_t *vp, enum vcache_state from, enum vcache_state to,
+vstate_assert_change(vnode_t *vp, enum vnode_state from, enum vnode_state to,
     const char *func, int line)
 {
-       struct vcache_node *node = VP_TO_VN(vp);
+       vnode_impl_t *node = VNODE_TO_VIMPL(vp);
 
        KASSERTMSG(mutex_owned(vp->v_interlock), "at %s:%d", func, line);
-       if (from == VN_LOADING)
+       if (from == VS_LOADING)
                KASSERTMSG(mutex_owned(&vcache.lock), "at %s:%d", func, line);
 
-       if (from == VN_MARKER)
+       if (from == VS_MARKER)
                vnpanic(vp, "from is %s at %s:%d",
                    vstate_name(from), func, line);
-       if (to == VN_MARKER)
+       if (to == VS_MARKER)
                vnpanic(vp, "to is %s at %s:%d",
                    vstate_name(to), func, line);
-       if (node->vn_state != from)
+       if (node->vi_state != from)
                vnpanic(vp, "from is %s, expected %s at %s:%d\n",
-                   vstate_name(node->vn_state), vstate_name(from), func, line);
+                   vstate_name(node->vi_state), vstate_name(from), func, line);
 
-       node->vn_state = to;
-       if (from == VN_LOADING)
+       node->vi_state = to;
+       if (from == VS_LOADING)
                cv_broadcast(&vcache.cv);
-       if (to == VN_ACTIVE || to == VN_RECLAIMED)
+       if (to == VS_ACTIVE || to == VS_RECLAIMED)
                cv_broadcast(&vp->v_cv);
 }
 
 #else /* defined(DIAGNOSTIC) */
 
 #define VSTATE_GET(vp) \
-       (VP_TO_VN((vp))->vn_state)
+       (VNODE_TO_VIMPL((vp))->vi_state)
 #define VSTATE_CHANGE(vp, from, to) \
        vstate_change((vp), (from), (to))
 #define VSTATE_WAIT_STABLE(vp) \
@@ -374,21 +375,21 @@
 static void
 vstate_wait_stable(vnode_t *vp)
 {
-       struct vcache_node *node = VP_TO_VN(vp);
+       vnode_impl_t *node = VNODE_TO_VIMPL(vp);
 
-       while (node->vn_state != VN_ACTIVE && node->vn_state != VN_RECLAIMED)
+       while (node->vi_state != VS_ACTIVE && node->vi_state != VS_RECLAIMED)
                cv_wait(&vp->v_cv, vp->v_interlock);
 }
 
 static void
-vstate_change(vnode_t *vp, enum vcache_state from, enum vcache_state to)
+vstate_change(vnode_t *vp, enum vnode_state from, enum vnode_state to)
 {
-       struct vcache_node *node = VP_TO_VN(vp);
+       vnode_impl_t *node = VNODE_TO_VIMPL(vp);
 
-       node->vn_state = to;
-       if (from == VN_LOADING)
+       node->vi_state = to;
+       if (from == VS_LOADING)
                cv_broadcast(&vcache.cv);
-       if (to == VN_ACTIVE || to == VN_RECLAIMED)
+       if (to == VS_ACTIVE || to == VS_RECLAIMED)
                cv_broadcast(&vp->v_cv);
 }
 
@@ -427,16 +428,16 @@
 vnode_t *
 vnalloc_marker(struct mount *mp)
 {
-       struct vcache_node *node;
+       vnode_impl_t *node;
        vnode_t *vp;
 
        node = pool_cache_get(vcache.pool, PR_WAITOK);
        memset(node, 0, sizeof(*node));
-       vp = VN_TO_VP(node);
+       vp = VIMPL_TO_VNODE(node);
        uvm_obj_init(&vp->v_uobj, &uvm_vnodeops, true, 0);
        vp->v_mount = mp;
        vp->v_type = VBAD;
-       node->vn_state = VN_MARKER;
+       node->vi_state = VS_MARKER;
 
        return vp;
 }
@@ -447,10 +448,10 @@
 void
 vnfree_marker(vnode_t *vp)
 {
-       struct vcache_node *node;
+       vnode_impl_t *node;
 
-       node = VP_TO_VN(vp);
-       KASSERT(node->vn_state == VN_MARKER);
+       node = VNODE_TO_VIMPL(vp);
+       KASSERT(node->vi_state == VS_MARKER);
        uvm_obj_destroy(&vp->v_uobj, true);
        pool_cache_put(vcache.pool, node);
 }
@@ -462,7 +463,7 @@
 vnis_marker(vnode_t *vp)
 {
 
-       return (VP_TO_VN(vp)->vn_state == VN_MARKER);
+       return (VNODE_TO_VIMPL(vp)->vi_state == VS_MARKER);
 }
 
 /*
@@ -589,13 +590,13 @@
  *
  * => Must be called with v_interlock held.
  *
- * If state is VN_RECLAIMING, the vnode may be eliminated in vcache_reclaim().
+ * If state is VS_RECLAIMING, the vnode may be eliminated in vcache_reclaim().
  * In that case, we cannot grab the vnode, so the process is awakened when
  * the transition is completed, and an error returned to indicate that the
  * vnode is no longer usable.
  *



Home | Main Index | Thread Index | Old Index