summaryrefslogtreecommitdiff
path: root/usr/src/cmd/mdb/common/modules/smbfs/smbfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/mdb/common/modules/smbfs/smbfs.c')
-rw-r--r--usr/src/cmd/mdb/common/modules/smbfs/smbfs.c176
1 files changed, 31 insertions, 145 deletions
diff --git a/usr/src/cmd/mdb/common/modules/smbfs/smbfs.c b/usr/src/cmd/mdb/common/modules/smbfs/smbfs.c
index 11aeb9f081..4841a41cd8 100644
--- a/usr/src/cmd/mdb/common/modules/smbfs/smbfs.c
+++ b/usr/src/cmd/mdb/common/modules/smbfs/smbfs.c
@@ -20,13 +20,10 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/mdb_modapi.h>
#include <sys/types.h>
#include <sys/refstr_impl.h>
@@ -176,138 +173,29 @@ smbfs_vfs_help(void)
}
/*
- * Walker for the smbnode hash table.
- */
-
-typedef struct smbnode_walk_data {
- rhashq_t *smbtab; /* (our copy of) the smbtable */
- int tabsize; /* size of table */
- int nextidx; /* next bucket index */
- uintptr_t buckptr; /* target addr of current bucket */
- uintptr_t nodeptr; /* target addr of current smbnode */
- smbnode_t node; /* scratch space for _step */
-} smbnode_walk_data_t;
-
-int
-smbnode_walk_init(mdb_walk_state_t *wsp)
-{
- size_t tabsz_bytes;
- int tabsize;
- uintptr_t smbtab;
- smbnode_walk_data_t *smbw;
-
- if (wsp->walk_addr != NULL) {
- mdb_warn("smbnode only supports global walks\n");
- return (WALK_ERR);
- }
-
- if (mdb_readvar(&tabsize, "smbtablesize") == -1) {
- mdb_warn("failed to read `smbtablesize'\n");
- return (WALK_ERR);
- }
-
- if (tabsize == 0) {
- return (WALK_DONE);
- }
-
- if (mdb_readvar(&smbtab, "smbtable") == -1) {
- mdb_warn("failed to read `smbtable'\n");
- return (WALK_ERR);
- }
-
- smbw = mdb_alloc(sizeof (*smbw), UM_SLEEP | UM_GC);
-
- tabsz_bytes = tabsize * sizeof (rhashq_t);
- smbw->smbtab = mdb_alloc(tabsz_bytes, UM_SLEEP | UM_GC);
- if (mdb_vread(smbw->smbtab, tabsz_bytes, smbtab) != tabsz_bytes) {
- mdb_warn("failed to read in smbtable from %p", smbtab);
- return (WALK_ERR);
- }
- smbw->tabsize = tabsize;
- smbw->nextidx = 1;
- smbw->buckptr = smbtab;
- smbw->nodeptr = (uintptr_t)smbw->smbtab[0].r_hashf;
- wsp->walk_data = smbw;
-
- return (WALK_NEXT);
-}
-
-int
-smbnode_walk_step(mdb_walk_state_t *wsp)
-{
- smbnode_walk_data_t *smbw = wsp->walk_data;
- int status;
-
-next_bucket:
- while (smbw->nodeptr == smbw->buckptr &&
- smbw->nextidx < smbw->tabsize) {
-
- /* Skip an empty bucket */
- rhashq_t *h = &smbw->smbtab[smbw->nextidx];
- smbw->nodeptr = (uintptr_t)h->r_hashf;
- smbw->nextidx++;
- smbw->buckptr += sizeof (rhashq_t);
- }
-
- if (smbw->nodeptr == smbw->buckptr)
- return (WALK_DONE);
-
- if (mdb_vread(&smbw->node, sizeof (smbw->node),
- smbw->nodeptr) != sizeof (smbw->node)) {
- mdb_warn("failed to read smbnode at %p in bucket %p\n",
- smbw->nodeptr, smbw->buckptr);
- /* Proceed with next bucket. */
- smbw->nodeptr = smbw->buckptr;
- goto next_bucket;
- }
-
- status = wsp->walk_callback(smbw->nodeptr,
- &smbw->node, wsp->walk_cbdata);
-
- /* Move to next node in this bucket */
- smbw->nodeptr = (uintptr_t)smbw->node.r_hashf;
-
- return (status);
-}
-
-/*ARGSUSED*/
-void
-smbnode_walk_fini(mdb_walk_state_t *wsp)
-{
- /* UM_GC takes care of it all. */
-}
-
-/*
* Dcmd (and callback function) to print a summary of
- * all smbnodes in the node hash table.
+ * all smbnodes in the node "hash" (cache) AVL tree.
*/
-typedef struct smbnode_cbdata {
+typedef struct smbfs_node_cbdata {
int flags;
int printed_header;
- uintptr_t smi; /* optional filtering by VFS */
- /* TODO: only nodes with a given [-h]ash */
- vnode_t vn; /* scratch space for smbnode_cb */
-} smbnode_cbdata_t;
+ vnode_t vn;
+} smbfs_node_cbdata_t;
int
-smbnode_cb(uintptr_t addr, const void *data, void *arg)
+smbfs_node_cb(uintptr_t addr, const void *data, void *arg)
{
const smbnode_t *np = data;
- smbnode_cbdata_t *cbd = arg;
-
- /* Optional filtering by mount point. */
- if (cbd->smi && cbd->smi != (uintptr_t)np->n_mount) {
- return (WALK_NEXT);
- }
+ smbfs_node_cbdata_t *cbd = arg;
if (cbd->printed_header == 0) {
cbd->printed_header = 1;
- mdb_printf("// smbnode vnode rpath\n");
+ mdb_printf("// vnode smbnode rpath\n");
}
- mdb_printf(" %-p", addr); /* smbnode */
mdb_printf(" %-p", (uintptr_t)np->r_vnode);
+ mdb_printf(" %-p", addr); /* smbnode */
print_str((uintptr_t)np->n_rpath);
mdb_printf("\n");
@@ -320,9 +208,8 @@ smbnode_cb(uintptr_t addr, const void *data, void *arg)
(uintptr_t)np->r_vnode);
} else {
/* Interesting parts of vnode_t */
- mdb_printf("v_type: %d v_path:",
- cbd->vn.v_type);
- print_str((uintptr_t)cbd->vn.v_path);
+ mdb_printf("v_type=%d v_count=%d",
+ cbd->vn.v_type, cbd->vn.v_count);
mdb_printf("\n");
}
mdb_dec_indent(2);
@@ -332,55 +219,54 @@ smbnode_cb(uintptr_t addr, const void *data, void *arg)
}
int
-smbnode_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbfs_node_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
- smbnode_cbdata_t *cbd;
- smbnode_t *np;
+ smbfs_node_cbdata_t *cbd;
cbd = mdb_zalloc(sizeof (*cbd), UM_SLEEP | UM_GC);
if (mdb_getopts(argc, argv,
'v', MDB_OPT_SETBITS, OPT_VERBOSE, &cbd->flags,
- 'm', MDB_OPT_UINTPTR, &cbd->smi, NULL) != argc) {
+ NULL) != argc) {
return (DCMD_USAGE);
}
if (!(flags & DCMD_ADDRSPEC)) {
- if (mdb_walk("smbnode", smbnode_cb, cbd)
- == -1) {
- mdb_warn("cannot walk smbnodes");
- return (DCMD_ERR);
- }
- return (DCMD_OK);
+ mdb_warn("expect an smbmntinfo_t addr");
+ return (DCMD_USAGE);
}
+ addr += OFFSETOF(smbmntinfo_t, smi_hash_avl);
- np = mdb_alloc(sizeof (*np), UM_SLEEP | UM_GC);
- SMBFS_OBJ_FETCH(addr, smbnode_t, np, DCMD_ERR);
- smbnode_cb(addr, np, cbd);
+ if (mdb_pwalk("genunix`avl", smbfs_node_cb, cbd, addr) == -1) {
+ mdb_warn("cannot walk smbfs nodes");
+ return (DCMD_ERR);
+ }
return (DCMD_OK);
}
void
-smbnode_help(void)
+smbfs_node_help(void)
{
mdb_printf("Options:\n"
- " -m mntinfo only show smbnodes belonging to mntinfo\n"
" -v be verbose when displaying smbnodes\n");
}
static const mdb_dcmd_t dcmds[] = {
- { "smbfs_vfs", "?[-v]",
+ {
+ "smbfs_vfs", "?[-v]",
"show smbfs-mounted vfs structs",
- smbfs_vfs_dcmd, smbfs_vfs_help },
- { "smbnode", "?[-v] [-m mntinfo]",
- "show smbnodes", smbnode_dcmd, smbnode_help },
+ smbfs_vfs_dcmd, smbfs_vfs_help
+ },
+ {
+ "smbfs_node", "?[-v]",
+ "given an smbmntinfo_t, list smbnodes",
+ smbfs_node_dcmd, smbfs_node_help
+ },
{NULL}
};
static const mdb_walker_t walkers[] = {
- { "smbnode", "walk smbnode hash table",
- smbnode_walk_init, smbnode_walk_step, smbnode_walk_fini },
{NULL}
};