Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add a function to print the fields of a vnode including ...
details: https://anonhg.NetBSD.org/src/rev/52b969461163
branches: trunk
changeset: 348709:52b969461163
user: hannken <hannken%NetBSD.org@localhost>
date: Thu Nov 03 11:04:21 2016 +0000
description:
Add a function to print the fields of a vnode including its implementation
and use it from vprint() and vfs_vnode_print().
Move vstate_name() to vfs_subr.c.
diffstat:
sys/kern/vfs_subr.c | 110 +++++++++++++++++++++++++++++++++-----------------
sys/kern/vfs_vnode.c | 47 +--------------------
sys/sys/vnode_impl.h | 6 +-
3 files changed, 78 insertions(+), 85 deletions(-)
diffs (252 lines):
diff -r 2aeb8795e651 -r 52b969461163 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c Thu Nov 03 11:03:31 2016 +0000
+++ b/sys/kern/vfs_subr.c Thu Nov 03 11:04:21 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_subr.c,v 1.450 2016/11/03 11:03:31 hannken Exp $ */
+/* $NetBSD: vfs_subr.c,v 1.451 2016/11/03 11:04:21 hannken Exp $ */
/*-
* Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.450 2016/11/03 11:03:31 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.451 2016/11/03 11:04:21 hannken Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -1056,13 +1056,78 @@
vap->va_bytes = VNOVAL;
}
+/*
+ * Vnode state to string.
+ */
+const char *
+vstate_name(enum vnode_state state)
+{
+
+ switch (state) {
+ case VS_MARKER:
+ return "MARKER";
+ case VS_LOADING:
+ return "LOADING";
+ case VS_ACTIVE:
+ return "ACTIVE";
+ case VS_BLOCKED:
+ return "BLOCKED";
+ case VS_RECLAIMING:
+ return "RECLAIMING";
+ case VS_RECLAIMED:
+ return "RECLAIMED";
+ default:
+ return "ILLEGAL";
+ }
+}
+
+/*
+ * Print a description of a vnode (common part).
+ */
+static void
+vprint_common(struct vnode *vp, const char *prefix,
+ void (*pr)(const char *, ...) __printflike(1, 2))
+{
+ int n;
+ char bf[96];
+ const uint8_t *cp;
+ vnode_impl_t *node;
+ const char * const vnode_tags[] = { VNODE_TAGS };
+ const char * const vnode_types[] = { VNODE_TYPES };
+ const char vnode_flagbits[] = VNODE_FLAGBITS;
+
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
#define ARRAY_PRINT(idx, arr) \
((unsigned int)(idx) < ARRAY_SIZE(arr) ? (arr)[(idx)] : "UNKNOWN")
-const char * const vnode_tags[] = { VNODE_TAGS };
-const char * const vnode_types[] = { VNODE_TYPES };
-const char vnode_flagbits[] = VNODE_FLAGBITS;
+ node = VNODE_TO_VIMPL(vp);
+
+ snprintb(bf, sizeof(bf),
+ vnode_flagbits, vp->v_iflag | vp->v_vflag | vp->v_uflag);
+
+ (*pr)("vnode %p flags %s\n", vp, bf);
+ (*pr)("%stag %s(%d) type %s(%d) mount %p typedata %p\n", prefix,
+ ARRAY_PRINT(vp->v_tag, vnode_tags), vp->v_tag,
+ ARRAY_PRINT(vp->v_type, vnode_types), vp->v_type,
+ vp->v_mount, vp->v_mountedhere);
+ (*pr)("%susecount %d writecount %d holdcount %d\n", prefix,
+ vp->v_usecount, vp->v_writecount, vp->v_holdcnt);
+ (*pr)("%ssize %" PRIx64 " writesize %" PRIx64 " numoutput %d\n",
+ prefix, vp->v_size, vp->v_writesize, vp->v_numoutput);
+ (*pr)("%sfreelisthd %p data %p lock %p\n", prefix,
+ vp->v_freelisthd, vp->v_data, &vp->v_lock);
+
+ (*pr)("%sstate %s key(%p %zd)", prefix, vstate_name(node->vi_state),
+ node->vi_key.vk_mount, node->vi_key.vk_key_len);
+ n = node->vi_key.vk_key_len;
+ cp = node->vi_key.vk_key;
+ while (n-- > 0)
+ (*pr)(" %02x", *cp++);
+ (*pr)("\n");
+
+#undef ARRAY_PRINT
+#undef ARRAY_SIZE
+}
/*
* Print out a description of a vnode.
@@ -1070,22 +1135,10 @@
void
vprint(const char *label, struct vnode *vp)
{
- char bf[96];
- int flag;
-
- flag = vp->v_iflag | vp->v_vflag | vp->v_uflag;
- snprintb(bf, sizeof(bf), vnode_flagbits, flag);
if (label != NULL)
printf("%s: ", label);
- printf("vnode @ %p, flags (%s)\n\ttag %s(%d), type %s(%d), "
- "usecount %d, writecount %d, holdcount %d\n"
- "\tfreelisthd %p, mount %p, data %p lock %p\n",
- vp, bf, ARRAY_PRINT(vp->v_tag, vnode_tags), vp->v_tag,
- ARRAY_PRINT(vp->v_type, vnode_types), vp->v_type,
- vp->v_usecount, vp->v_writecount, vp->v_holdcnt,
- vp->v_freelisthd, vp->v_mount, vp->v_data, &vp->v_lock);
- vcache_print(vp, "\t", printf);
+ vprint_common(vp, "\t", printf);
if (vp->v_data != NULL) {
printf("\t");
VOP_PRINT(vp);
@@ -1463,27 +1516,10 @@
void
vfs_vnode_print(struct vnode *vp, int full, void (*pr)(const char *, ...))
{
- char bf[256];
uvm_object_printit(&vp->v_uobj, full, pr);
- snprintb(bf, sizeof(bf),
- vnode_flagbits, vp->v_iflag | vp->v_vflag | vp->v_uflag);
- (*pr)("\nVNODE flags %s\n", bf);
- (*pr)("mp %p numoutput %d size 0x%llx writesize 0x%llx\n",
- vp->v_mount, vp->v_numoutput, vp->v_size, vp->v_writesize);
-
- (*pr)("data %p writecount %ld holdcnt %ld\n",
- vp->v_data, vp->v_writecount, vp->v_holdcnt);
-
- (*pr)("tag %s(%d) type %s(%d) mount %p typedata %p\n",
- ARRAY_PRINT(vp->v_tag, vnode_tags), vp->v_tag,
- ARRAY_PRINT(vp->v_type, vnode_types), vp->v_type,
- vp->v_mount, vp->v_mountedhere);
-
- (*pr)("v_lock %p\n", &vp->v_lock);
-
- vcache_print(vp, "", pr);
-
+ (*pr)("\n");
+ vprint_common(vp, "", printf);
if (full) {
struct buf *bp;
diff -r 2aeb8795e651 -r 52b969461163 sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c Thu Nov 03 11:03:31 2016 +0000
+++ b/sys/kern/vfs_vnode.c Thu Nov 03 11:04:21 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnode.c,v 1.58 2016/11/03 11:03:31 hannken Exp $ */
+/* $NetBSD: vfs_vnode.c,v 1.59 2016/11/03 11:04:21 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.58 2016/11/03 11:03:31 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.59 2016/11/03 11:04:21 hannken Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -232,28 +232,6 @@
/* Vnode state operations and diagnostics. */
-static const char *
-vstate_name(enum vnode_state state)
-{
-
- switch (state) {
- case VS_MARKER:
- return "MARKER";
- case VS_LOADING:
- return "LOADING";
- case VS_ACTIVE:
- return "ACTIVE";
- case VS_BLOCKED:
- return "BLOCKED";
- case VS_RECLAIMING:
- return "RECLAIMING";
- case VS_RECLAIMED:
- return "RECLAIMED";
- default:
- return "ILLEGAL";
- }
-}
-
#if defined(DIAGNOSTIC)
#define VSTATE_GET(vp) \
@@ -1577,27 +1555,6 @@
}
/*
- * Print a vcache node.
- */
-void
-vcache_print(vnode_t *vp, const char *prefix, void (*pr)(const char *, ...))
-{
- int n;
- const uint8_t *cp;
- vnode_impl_t *node;
-
- node = VNODE_TO_VIMPL(vp);
- n = node->vi_key.vk_key_len;
- cp = node->vi_key.vk_key;
-
- (*pr)("%sstate %s, key(%d)", prefix, vstate_name(node->vi_state), n);
-
- while (n-- > 0)
- (*pr)(" %02x", *cp++);
- (*pr)("\n");
-}
-
-/*
* Update outstanding I/O count and do wakeup if requested.
*/
void
diff -r 2aeb8795e651 -r 52b969461163 sys/sys/vnode_impl.h
--- a/sys/sys/vnode_impl.h Thu Nov 03 11:03:31 2016 +0000
+++ b/sys/sys/vnode_impl.h Thu Nov 03 11:04:21 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnode_impl.h,v 1.1 2016/11/03 11:03:31 hannken Exp $ */
+/* $NetBSD: vnode_impl.h,v 1.2 2016/11/03 11:04:21 hannken Exp $ */
/*-
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -61,11 +61,11 @@
/*
* Vnode manipulation functions.
*/
+const char *
+ vstate_name(enum vnode_state);
vnode_t *
vnalloc_marker(struct mount *);
void vnfree_marker(vnode_t *);
bool vnis_marker(vnode_t *);
-void vcache_print(vnode_t *, const char *,
- void (*)(const char *, ...) __printflike(1, 2));
#endif /* !_SYS_VNODE_IMPL_H_ */
Home |
Main Index |
Thread Index |
Old Index