md.c revision 8452:89d32dfdae6e
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26#include <sys/mdb_modapi.h> 27 28 29int md_verbose = 0; /* be verbose about the addresses */ 30 31extern int metaset(uintptr_t, uint_t, int, const mdb_arg_t *); 32extern int metastat(uintptr_t, uint_t, int, const mdb_arg_t *); 33extern int set_io(uintptr_t, uint_t, int, const mdb_arg_t *); 34extern int dumpnamespace(uintptr_t, uint_t, int, const mdb_arg_t *); 35extern int dumpsetaddr(uintptr_t, uint_t, int, const mdb_arg_t *); 36extern int dumphotspare(uintptr_t, uint_t, int, const mdb_arg_t *); 37extern int printmmbm(uintptr_t, uint_t, int, const mdb_arg_t *); 38extern void set_io_help(); 39 40/* from mdbgen */ 41extern int mddb_db_walk_init(mdb_walk_state_t *); 42extern int mddb_db_walk_step(mdb_walk_state_t *); 43extern int mddb_de_ic_walk_init(mdb_walk_state_t *); 44extern int mddb_de_ic_walk_step(mdb_walk_state_t *); 45extern int hotsparepool_walk_init(mdb_walk_state_t *); 46extern int hotsparepool_walk_step(mdb_walk_state_t *); 47extern void hotsparepool_walk_fini(mdb_walk_state_t *); 48extern int didnamespace_walk_init(mdb_walk_state_t *); 49extern int didnamespace_walk_step(mdb_walk_state_t *); 50extern void didnamespace_walk_fini(mdb_walk_state_t *); 51extern int namespace_walk_init(mdb_walk_state_t *); 52extern int namespace_walk_step(mdb_walk_state_t *); 53extern void namespace_walk_fini(mdb_walk_state_t *); 54extern int sets_walk_init(mdb_walk_state_t *); 55extern int sets_walk_step(mdb_walk_state_t *); 56extern void sets_walk_fini(mdb_walk_state_t *); 57extern int units_walk_init(mdb_walk_state_t *); 58extern int units_walk_step(mdb_walk_state_t *); 59extern void units_walk_fini(mdb_walk_state_t *); 60extern int simple_de_ic(uintptr_t, uint_t, int, const mdb_arg_t *); 61int md_set_verbose(uintptr_t, uint_t, int, const mdb_arg_t *); 62 63 64const mdb_dcmd_t dcmds[] = { 65 { "md_verbose", NULL, "toggle verbose mode for SVM dcmds", 66 md_set_verbose }, 67 { "metaset", NULL, "list SVM metasets", metaset }, 68 { "metastat", "[-v]", "list SVM metadevices", 69 metastat }, 70 { "set_io", NULL, "show the pending IO counts", set_io, 71 set_io_help }, 72 { "dumpnamespace", "[-s setname]", "dump the SVM name space", 73 dumpnamespace }, 74 { "dumphotspare", NULL, "dump the hot spare pools", 75 dumphotspare }, 76 { "dumpsetaddr", "[-s setname]", "dump the SVM set addresses", 77 dumpsetaddr }, 78 { "simple_de_ic", NULL, "simple mddb_de_ic_t", 79 simple_de_ic }, 80 { "printmmbm", NULL, "print bitmaps for given mm_unit_t", 81 printmmbm }, 82 { NULL } 83}; 84 85static const mdb_walker_t walkers[] = { 86 { "mddb_db", "walk list of mddb_db_t structures", 87 mddb_db_walk_init, mddb_db_walk_step, NULL, NULL }, 88 { "mddb_de_ic", "walk list of mddb_de_t structures", 89 mddb_de_ic_walk_init, mddb_de_ic_walk_step, NULL, NULL }, 90 { "hotsparepool", "walk list of hotspare pools", 91 hotsparepool_walk_init, hotsparepool_walk_step, 92 hotsparepool_walk_fini, NULL }, 93 { "didnamespace", "walk the did namespace", 94 didnamespace_walk_init, didnamespace_walk_step, 95 didnamespace_walk_fini, NULL }, 96 { "namespace", "walk the namespace", 97 namespace_walk_init, namespace_walk_step, namespace_walk_fini, 98 NULL }, 99 { "md_sets", "walk list of sets", 100 sets_walk_init, sets_walk_step, sets_walk_fini, NULL }, 101 { "md_units", "walk list of unit structures", 102 units_walk_init, units_walk_step, units_walk_fini, NULL }, 103 { NULL } 104}; 105 106static const mdb_modinfo_t modinfo = { 107 MDB_API_VERSION, dcmds, walkers 108}; 109 110const mdb_modinfo_t * 111_mdb_init(void) 112{ 113 return (&modinfo); 114} 115 116 117/* ARGSUSED */ 118int 119md_set_verbose(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 120{ 121 md_verbose = !md_verbose; 122 123 if ((flags & DCMD_ADDRSPEC) != 0 || argc != 0) 124 return (DCMD_USAGE); 125 126 mdb_printf("Verbose mode is now %d\n", md_verbose); 127 return (DCMD_OK); 128} 129