usr/src/cmd/mdb/common/modules/zfs/zfs.c
author eschrock
Tue, 12 Jun 2007 13:18:17 -0700
changeset 4451 24fbf2d7a5d7
parent 4217 3411a82f178f
child 4787 602d3f97842c
permissions -rw-r--r--
PSARC 2007/197 ZFS hotplug PSARC 2007/283 FMA for ZFS Phase 2 6401126 ZFS DE should verify that diagnosis is still valid before solving cases 6500545 ZFS does not handle changes in devids 6508521 zpool online should warn when it is being used incorrectly 6509807 ZFS checksum ereports are not being posted 6514712 zfs_nicenum() doesn't work with perfectly-sized buffers 6520510 media state doesn't get updated properly on device removal 6520513 ZFS should have better support for device removal 6520514 vdev state should be controlled through a single ioctl() 6520519 ZFS should diagnose faulty devices 6520947 ZFS DE should close cases which no longer apply 6521393 ZFS case timeout should be FMD_TYPE_TIME 6521624 fmd_hash_walk() can dump core when given a bad address 6521946 ZFS DE needlessly subscribes to faults 6522085 ZFS dictionary files contain spelling errors 6523185 vdev_reopen() doesn't correctly propagate state 6523555 'zpool online' should be less chatty unless something goes wrong 6527379 zpool(1M) should not try to open faulted devices 6527700 ZFS should post a sysevent when topology changes 6528194 lofi should support force unmap and DKIO_DEV_GONE 6528732 ZFS should store physical device path in addition to /dev path 6532635 ZFS keeps devices open unnecessarily 6532979 bad argument to ZFS_IOC_VDEV_ATTACH can panic system 6567983 deadlock with spa_scrub_thread() and spa_namespace_lock
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     1
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     2
 * CDDL HEADER START
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     3
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 952
diff changeset
     5
 * Common Development and Distribution License (the "License").
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 952
diff changeset
     6
 * You may not use this file except in compliance with the License.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     7
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    11
 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    12
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    18
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    19
 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    20
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    21
/*
3361
a3d194896a76 6480230 ::walk spa|::walk zms_freelist cause mdb to core dump
ck153898
parents: 3158
diff changeset
    22
 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    23
 * Use is subject to license terms.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    24
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    25
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    26
#pragma ident	"%Z%%M%	%I%	%E% SMI"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    27
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    28
#include <mdb/mdb_ctf.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    29
#include <sys/zfs_context.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    30
#include <sys/mdb_modapi.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    31
#include <sys/dbuf.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    32
#include <sys/dmu_objset.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    33
#include <sys/dsl_dir.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    34
#include <sys/dsl_pool.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    35
#include <sys/metaslab_impl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    36
#include <sys/space_map.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    37
#include <sys/list.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    38
#include <sys/spa_impl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    39
#include <sys/vdev_impl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    40
#include <sys/zio_compress.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    41
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    42
#ifndef _KERNEL
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    43
#include "../genunix/list.h"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    44
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    45
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    46
#ifdef _KERNEL
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    47
#define	ZFS_OBJ_NAME	"zfs"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    48
#else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    49
#define	ZFS_OBJ_NAME	"libzpool.so.1"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    50
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    51
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    52
static char *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    53
local_strdup(const char *s)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    54
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    55
	char *s1 = mdb_alloc(strlen(s) + 1, UM_SLEEP);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    56
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    57
	(void) strcpy(s1, s);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    58
	return (s1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    59
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    60
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    61
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    62
getmember(uintptr_t addr, const char *type, mdb_ctf_id_t *idp,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    63
    const char *member, int len, void *buf)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    64
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    65
	mdb_ctf_id_t id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    66
	ulong_t off;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    67
	char name[64];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    68
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    69
	if (idp == NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    70
		if (mdb_ctf_lookup_by_name(type, &id) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    71
			mdb_warn("couldn't find type %s", type);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    72
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    73
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    74
		idp = &id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    75
	} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    76
		type = name;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    77
		mdb_ctf_type_name(*idp, name, sizeof (name));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    78
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    79
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    80
	if (mdb_ctf_offsetof(*idp, member, &off) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    81
		mdb_warn("couldn't find member %s of type %s\n", member, type);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    82
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    83
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    84
	if (off % 8 != 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    85
		mdb_warn("member %s of type %s is unsupported bitfield",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    86
		    member, type);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    87
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    88
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    89
	off /= 8;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    90
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    91
	if (mdb_vread(buf, len, addr + off) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    92
		mdb_warn("failed to read %s from %s at %p",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    93
		    member, type, addr + off);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    94
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    95
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    96
	/* mdb_warn("read %s from %s at %p+%llx\n", member, type, addr, off); */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    97
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    98
	return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    99
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   100
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   101
#define	GETMEMB(addr, type, member, dest) \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   102
	getmember(addr, #type, NULL, #member, sizeof (dest), &(dest))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   103
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   104
#define	GETMEMBID(addr, ctfid, member, dest) \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   105
	getmember(addr, NULL, ctfid, #member, sizeof (dest), &(dest))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   106
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   107
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   108
getrefcount(uintptr_t addr, mdb_ctf_id_t *id,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   109
    const char *member, uint64_t *rc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   110
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   111
	static int gotid;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   112
	static mdb_ctf_id_t rc_id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   113
	ulong_t off;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   114
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   115
	if (!gotid) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   116
		if (mdb_ctf_lookup_by_name("struct refcount", &rc_id) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   117
			mdb_warn("couldn't find struct refcount");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   118
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   119
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   120
		gotid = TRUE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   121
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   122
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   123
	if (mdb_ctf_offsetof(*id, member, &off) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   124
		char name[64];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   125
		mdb_ctf_type_name(*id, name, sizeof (name));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   126
		mdb_warn("couldn't find member %s of type %s\n", member, name);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   127
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   128
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   129
	off /= 8;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   130
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   131
	return (GETMEMBID(addr + off, &rc_id, rc_count, *rc));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   132
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   133
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   134
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   135
read_symbol(char *sym_name, void **bufp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   136
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   137
	GElf_Sym sym;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   138
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   139
	if (mdb_lookup_by_obj(MDB_TGT_OBJ_EVERY, sym_name, &sym)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   140
		mdb_warn("can't find symbol %s", sym_name);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   141
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   142
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   143
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   144
	*bufp = mdb_alloc(sym.st_size, UM_SLEEP);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   145
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   146
	if (mdb_vread(*bufp, sym.st_size, sym.st_value) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   147
		mdb_warn("can't read data for symbol %s", sym_name);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   148
		mdb_free(*bufp, sym.st_size);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   149
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   150
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   151
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   152
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   153
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   154
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   155
static int verbose;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   156
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   157
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   158
freelist_walk_init(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   159
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   160
	if (wsp->walk_addr == NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   161
		mdb_warn("must supply starting address\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   162
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   163
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   164
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   165
	wsp->walk_data = 0;  /* Index into the freelist */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   166
	return (WALK_NEXT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   167
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   168
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   169
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   170
freelist_walk_step(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   171
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   172
	uint64_t entry;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   173
	uintptr_t number = (uintptr_t)wsp->walk_data;
3361
a3d194896a76 6480230 ::walk spa|::walk zms_freelist cause mdb to core dump
ck153898
parents: 3158
diff changeset
   174
	char *ddata[] = { "ALLOC", "FREE", "CONDENSE", "INVALID",
a3d194896a76 6480230 ::walk spa|::walk zms_freelist cause mdb to core dump
ck153898
parents: 3158
diff changeset
   175
			    "INVALID", "INVALID", "INVALID", "INVALID" };
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   176
	int mapshift = SPA_MINBLOCKSHIFT;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   177
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   178
	if (mdb_vread(&entry, sizeof (entry), wsp->walk_addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   179
		mdb_warn("failed to read freelist entry %p", wsp->walk_addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   180
		return (WALK_DONE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   181
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   182
	wsp->walk_addr += sizeof (entry);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   183
	wsp->walk_data = (void *)(number + 1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   184
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   185
	if (SM_DEBUG_DECODE(entry)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   186
		mdb_printf("DEBUG: %3u  %10s: txg=%llu  pass=%llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   187
		    number,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   188
		    ddata[SM_DEBUG_ACTION_DECODE(entry)],
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   189
		    SM_DEBUG_TXG_DECODE(entry),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   190
		    SM_DEBUG_SYNCPASS_DECODE(entry));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   191
	} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   192
		mdb_printf("Entry: %3u  offsets=%08llx-%08llx  type=%c  "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   193
		    "size=%06llx", number,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   194
		    SM_OFFSET_DECODE(entry) << mapshift,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   195
		    (SM_OFFSET_DECODE(entry) + SM_RUN_DECODE(entry)) <<
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   196
		    mapshift,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   197
		    SM_TYPE_DECODE(entry) == SM_ALLOC ? 'A' : 'F',
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   198
		    SM_RUN_DECODE(entry) << mapshift);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   199
		if (verbose)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   200
			mdb_printf("      (raw=%012llx)\n", entry);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   201
		mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   202
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   203
	return (WALK_NEXT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   204
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   205
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   206
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   207
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   208
dataset_name(uintptr_t addr, char *buf)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   209
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   210
	static int gotid;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   211
	static mdb_ctf_id_t dd_id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   212
	uintptr_t dd_parent;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   213
	char dd_myname[MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   214
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   215
	if (!gotid) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   216
		if (mdb_ctf_lookup_by_name("struct dsl_dir",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   217
		    &dd_id) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   218
			mdb_warn("couldn't find struct dsl_dir");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   219
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   220
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   221
		gotid = TRUE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   222
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   223
	if (GETMEMBID(addr, &dd_id, dd_parent, dd_parent) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   224
	    GETMEMBID(addr, &dd_id, dd_myname, dd_myname)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   225
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   226
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   227
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   228
	if (dd_parent) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   229
		if (dataset_name(dd_parent, buf))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   230
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   231
		strcat(buf, "/");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   232
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   233
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   234
	if (dd_myname[0])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   235
		strcat(buf, dd_myname);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   236
	else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   237
		strcat(buf, "???");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   238
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   239
	return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   240
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   241
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   242
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   243
objset_name(uintptr_t addr, char *buf)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   244
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   245
	static int gotid;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   246
	static mdb_ctf_id_t osi_id, ds_id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   247
	uintptr_t os_dsl_dataset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   248
	char ds_snapname[MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   249
	uintptr_t ds_dir;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   250
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   251
	buf[0] = '\0';
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   252
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   253
	if (!gotid) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   254
		if (mdb_ctf_lookup_by_name("struct objset_impl",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   255
		    &osi_id) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   256
			mdb_warn("couldn't find struct objset_impl");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   257
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   258
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   259
		if (mdb_ctf_lookup_by_name("struct dsl_dataset",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   260
		    &ds_id) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   261
			mdb_warn("couldn't find struct dsl_dataset");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   262
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   263
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   264
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   265
		gotid = TRUE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   266
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   267
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   268
	if (GETMEMBID(addr, &osi_id, os_dsl_dataset, os_dsl_dataset))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   269
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   270
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   271
	if (os_dsl_dataset == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   272
		strcat(buf, "mos");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   273
		return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   274
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   275
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   276
	if (GETMEMBID(os_dsl_dataset, &ds_id, ds_snapname, ds_snapname) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   277
	    GETMEMBID(os_dsl_dataset, &ds_id, ds_dir, ds_dir)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   278
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   279
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   280
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   281
	if (ds_dir && dataset_name(ds_dir, buf))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   282
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   283
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   284
	if (ds_snapname[0]) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   285
		strcat(buf, "@");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   286
		strcat(buf, ds_snapname);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   287
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   288
	return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   289
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   290
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   291
static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   292
enum_lookup(char *out, size_t size, mdb_ctf_id_t id, int val,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   293
    const char *prefix)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   294
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   295
	const char *cp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   296
	size_t len = strlen(prefix);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   297
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   298
	if ((cp = mdb_ctf_enum_name(id, val)) != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   299
		if (strncmp(cp, prefix, len) == 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   300
			cp += len;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   301
		(void) strncpy(out, cp, size);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   302
	} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   303
		mdb_snprintf(out, size, "? (%d)", val);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   304
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   305
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   306
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   307
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   308
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   309
zio_pipeline(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   310
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   311
	mdb_ctf_id_t pipe_enum;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   312
	int i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   313
	char stage[1024];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   314
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   315
	if (mdb_ctf_lookup_by_name("enum zio_stage", &pipe_enum) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   316
		mdb_warn("Could not find enum zio_stage");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   317
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   318
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   319
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   320
	for (i = 0; i < 32; i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   321
		if (addr & (1U << i)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   322
			enum_lookup(stage, sizeof (stage), pipe_enum, i,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   323
			    "ZIO_STAGE_");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   324
			mdb_printf("    %s\n", stage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   325
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   326
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   327
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   328
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   329
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   330
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   331
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   332
static int
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   333
zfs_params(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   334
{
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   335
	/*
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   336
	 * This table can be approximately generated by running:
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   337
	 * egrep "^[a-z0-9_]+ [a-z0-9_]+( =.*)?;" *.c | cut -d ' ' -f 2
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   338
	 */
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   339
	static const char *params[] = {
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   340
		"arc_reduce_dnlc_percent",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   341
		"zfs_arc_max",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   342
		"zfs_arc_min",
3158
f30a3849aa23 6493923 nfsfind on ZFS filesystem quickly depletes memory in a 1GB system
maybee
parents: 3059
diff changeset
   343
		"arc_shrink_shift",
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   344
		"zfs_mdcomp_disable",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   345
		"zfs_prefetch_disable",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   346
		"zfetch_max_streams",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   347
		"zfetch_min_sec_reap",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   348
		"zfetch_block_cap",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   349
		"zfetch_array_rd_sz",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   350
		"zfs_default_bs",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   351
		"zfs_default_ibs",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   352
		"metaslab_aliquot",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   353
		"reference_tracking_enable",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   354
		"reference_history",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   355
		"zio_taskq_threads",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   356
		"spa_max_replication_override",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   357
		"spa_mode",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   358
		"zfs_flags",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   359
		"txg_time",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   360
		"zfs_vdev_cache_max",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   361
		"zfs_vdev_cache_size",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   362
		"zfs_vdev_cache_bshift",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   363
		"vdev_mirror_shift",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   364
		"zfs_vdev_max_pending",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   365
		"zfs_vdev_min_pending",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   366
		"zfs_scrub_limit",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   367
		"zfs_vdev_time_shift",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   368
		"zfs_vdev_ramp_rate",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   369
		"zfs_vdev_aggregation_limit",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   370
		"fzap_default_block_shift",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   371
		"zfs_immediate_write_sz",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   372
		"zfs_read_chunk_size",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   373
		"zil_disable",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   374
		"zfs_nocacheflush",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   375
		"zio_gang_bang",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   376
		"zio_injection_enabled",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   377
		"zvol_immediate_write_sz",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   378
	};
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   379
	int i;
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   380
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   381
	for (i = 0; i < sizeof (params) / sizeof (params[0]); i++) {
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   382
		int sz;
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   383
		uint64_t val64;
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   384
		uint32_t *val32p = (uint32_t *)&val64;
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   385
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   386
		sz = mdb_readvar(&val64, params[i]);
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   387
		if (sz == 4) {
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   388
			mdb_printf("%s = 0x%x\n", params[i], *val32p);
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   389
		} else if (sz == 8) {
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   390
			mdb_printf("%s = 0x%llx\n", params[i], val64);
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   391
		} else {
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   392
			mdb_warn("variable %s not found", params[i]);
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   393
		}
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   394
	}
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   395
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   396
	return (DCMD_OK);
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   397
}
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   398
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   399
/* ARGSUSED */
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   400
static int
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   401
blkptr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   402
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   403
	blkptr_t bp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   404
	dmu_object_type_info_t *doti;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   405
	zio_compress_info_t *zct;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   406
	zio_checksum_info_t *zci;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   407
	int i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   408
	char buf[MAXPATHLEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   409
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   410
	if (mdb_vread(&bp, sizeof (blkptr_t), addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   411
		mdb_warn("failed to read blkptr_t");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   412
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   413
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   414
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   415
	if (read_symbol("dmu_ot", (void **)&doti) != DCMD_OK)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   416
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   417
	for (i = 0; i < DMU_OT_NUMTYPES; i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   418
		mdb_readstr(buf, sizeof (buf), (uintptr_t)doti[i].ot_name);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   419
		doti[i].ot_name = local_strdup(buf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   420
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   421
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   422
	if (read_symbol("zio_checksum_table", (void **)&zci) != DCMD_OK)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   423
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   424
	for (i = 0; i < ZIO_CHECKSUM_FUNCTIONS; i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   425
		mdb_readstr(buf, sizeof (buf), (uintptr_t)zci[i].ci_name);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   426
		zci[i].ci_name = local_strdup(buf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   427
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   428
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   429
	if (read_symbol("zio_compress_table", (void **)&zct) != DCMD_OK)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   430
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   431
	for (i = 0; i < ZIO_COMPRESS_FUNCTIONS; i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   432
		mdb_readstr(buf, sizeof (buf), (uintptr_t)zct[i].ci_name);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   433
		zct[i].ci_name = local_strdup(buf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   434
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   435
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   436
	/*
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   437
	 * Super-ick warning:  This code is also duplicated in
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   438
	 * cmd/zdb.c .   Yeah, I hate code replication, too.
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   439
	 */
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   440
	for (i = 0; i < BP_GET_NDVAS(&bp); i++) {
1732
9e3ae798af31 6280668 pluggable block allocation policy
bonwick
parents: 1544
diff changeset
   441
		dva_t *dva = &bp.blk_dva[i];
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   442
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   443
		mdb_printf("DVA[%d]: vdev_id %lld / %llx\n", i,
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   444
		    DVA_GET_VDEV(dva), DVA_GET_OFFSET(dva));
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   445
		mdb_printf("DVA[%d]:       GANG: %-5s  GRID:  %04x\t"
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   446
		    "ASIZE: %llx\n", i, DVA_GET_GANG(dva) ? "TRUE" : "FALSE",
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   447
		    DVA_GET_GRID(dva), DVA_GET_ASIZE(dva));
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   448
		mdb_printf("DVA[%d]: :%llu:%llx:%llx:%s%s%s%s\n", i,
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   449
		    DVA_GET_VDEV(dva), DVA_GET_OFFSET(dva), BP_GET_PSIZE(&bp),
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   450
		    BP_SHOULD_BYTESWAP(&bp) ? "e" : "",
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   451
		    !DVA_GET_GANG(dva) && BP_GET_LEVEL(&bp) != 0 ? "i" : "",
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   452
		    DVA_GET_GANG(dva) ? "g" : "",
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   453
		    BP_GET_COMPRESS(&bp) != 0 ? "d" : "");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   454
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   455
	mdb_printf("LSIZE:  %-16llx\t\tPSIZE: %llx\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   456
	    BP_GET_LSIZE(&bp), BP_GET_PSIZE(&bp));
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   457
	mdb_printf("ENDIAN: %6s\t\t\t\t\tTYPE:  %s\n",
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   458
	    BP_GET_BYTEORDER(&bp) ? "LITTLE" : "BIG",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   459
	    doti[BP_GET_TYPE(&bp)].ot_name);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   460
	mdb_printf("BIRTH:  %-16llx   LEVEL: %-2d\tFILL:  %llx\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   461
	    bp.blk_birth, BP_GET_LEVEL(&bp), bp.blk_fill);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   462
	mdb_printf("CKFUNC: %-16s\t\tCOMP:  %s\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   463
	    zci[BP_GET_CHECKSUM(&bp)].ci_name,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   464
	    zct[BP_GET_COMPRESS(&bp)].ci_name);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   465
	mdb_printf("CKSUM:  %llx:%llx:%llx:%llx\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   466
	    bp.blk_cksum.zc_word[0],
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   467
	    bp.blk_cksum.zc_word[1],
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   468
	    bp.blk_cksum.zc_word[2],
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   469
	    bp.blk_cksum.zc_word[3]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   470
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   471
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   472
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   473
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   474
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   475
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   476
dbuf(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   477
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   478
	mdb_ctf_id_t id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   479
	dmu_buf_t db;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   480
	uintptr_t objset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   481
	uint8_t level;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   482
	uint64_t blkid;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   483
	uint64_t holds;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   484
	char objectname[32];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   485
	char blkidname[32];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   486
	char path[MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   487
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   488
	if (DCMD_HDRSPEC(flags)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   489
		mdb_printf("        addr object lvl blkid holds os\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   490
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   491
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   492
	if (mdb_ctf_lookup_by_name("struct dmu_buf_impl", &id) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   493
		mdb_warn("couldn't find struct dmu_buf_impl_t");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   494
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   495
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   496
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   497
	if (GETMEMBID(addr, &id, db_objset, objset) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   498
	    GETMEMBID(addr, &id, db, db) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   499
	    GETMEMBID(addr, &id, db_level, level) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   500
	    GETMEMBID(addr, &id, db_blkid, blkid)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   501
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   502
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   503
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   504
	if (getrefcount(addr, &id, "db_holds", &holds)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   505
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   506
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   507
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   508
	if (db.db_object == DMU_META_DNODE_OBJECT)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   509
		(void) strcpy(objectname, "mdn");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   510
	else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   511
		(void) mdb_snprintf(objectname, sizeof (objectname), "%llx",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   512
		    (u_longlong_t)db.db_object);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   513
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   514
	if (blkid == DB_BONUS_BLKID)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   515
		(void) strcpy(blkidname, "bonus");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   516
	else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   517
		(void) mdb_snprintf(blkidname, sizeof (blkidname), "%llx",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   518
		    (u_longlong_t)blkid);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   519
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   520
	if (objset_name(objset, path)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   521
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   522
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   523
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   524
	mdb_printf("%p %8s %1u %9s %2llu %s\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   525
	    addr, objectname, level, blkidname, holds, path);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   526
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   527
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   528
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   529
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   530
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   531
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   532
dbuf_stats(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   533
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   534
#define	HISTOSZ 32
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   535
	uintptr_t dbp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   536
	dmu_buf_impl_t db;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   537
	dbuf_hash_table_t ht;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   538
	uint64_t bucket, ndbufs;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   539
	uint64_t histo[HISTOSZ];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   540
	uint64_t histo2[HISTOSZ];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   541
	int i, maxidx;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   542
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   543
	if (mdb_readvar(&ht, "dbuf_hash_table") == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   544
		mdb_warn("failed to read 'dbuf_hash_table'");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   545
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   546
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   547
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   548
	for (i = 0; i < HISTOSZ; i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   549
		histo[i] = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   550
		histo2[i] = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   551
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   552
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   553
	ndbufs = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   554
	for (bucket = 0; bucket < ht.hash_table_mask+1; bucket++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   555
		int len;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   556
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   557
		if (mdb_vread(&dbp, sizeof (void *),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   558
		    (uintptr_t)(ht.hash_table+bucket)) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   559
			mdb_warn("failed to read hash bucket %u at %p",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   560
			    bucket, ht.hash_table+bucket);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   561
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   562
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   563
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   564
		len = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   565
		while (dbp != 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   566
			if (mdb_vread(&db, sizeof (dmu_buf_impl_t),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   567
			    dbp) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   568
				mdb_warn("failed to read dbuf at %p", dbp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   569
				return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   570
			}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   571
			dbp = (uintptr_t)db.db_hash_next;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   572
			for (i = MIN(len, HISTOSZ - 1); i >= 0; i--)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   573
				histo2[i]++;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   574
			len++;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   575
			ndbufs++;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   576
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   577
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   578
		if (len >= HISTOSZ)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   579
			len = HISTOSZ-1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   580
		histo[len]++;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   581
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   582
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   583
	mdb_printf("hash table has %llu buckets, %llu dbufs "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   584
	    "(avg %llu buckets/dbuf)\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   585
	    ht.hash_table_mask+1, ndbufs,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   586
	    (ht.hash_table_mask+1)/ndbufs);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   587
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   588
	mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   589
	maxidx = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   590
	for (i = 0; i < HISTOSZ; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   591
		if (histo[i] > 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   592
			maxidx = i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   593
	mdb_printf("hash chain length	number of buckets\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   594
	for (i = 0; i <= maxidx; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   595
		mdb_printf("%u			%llu\n", i, histo[i]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   596
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   597
	mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   598
	maxidx = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   599
	for (i = 0; i < HISTOSZ; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   600
		if (histo2[i] > 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   601
			maxidx = i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   602
	mdb_printf("hash chain depth	number of dbufs\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   603
	for (i = 0; i <= maxidx; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   604
		mdb_printf("%u or more		%llu	%llu%%\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   605
		    i, histo2[i], histo2[i]*100/ndbufs);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   606
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   607
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   608
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   609
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   610
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   611
typedef struct dbufs_data {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   612
	mdb_ctf_id_t id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   613
	uint64_t objset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   614
	uint64_t object;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   615
	uint64_t level;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   616
	uint64_t blkid;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   617
	char *osname;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   618
} dbufs_data_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   619
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   620
#define	DBUFS_UNSET	(0xbaddcafedeadbeefULL)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   621
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   622
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   623
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   624
dbufs_cb(uintptr_t addr, const void *unknown, void *arg)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   625
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   626
	dbufs_data_t *data = arg;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   627
	uintptr_t objset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   628
	dmu_buf_t db;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   629
	uint8_t level;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   630
	uint64_t blkid;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   631
	char osname[MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   632
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   633
	if (GETMEMBID(addr, &data->id, db_objset, objset) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   634
	    GETMEMBID(addr, &data->id, db, db) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   635
	    GETMEMBID(addr, &data->id, db_level, level) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   636
	    GETMEMBID(addr, &data->id, db_blkid, blkid)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   637
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   638
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   639
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   640
	if ((data->objset == DBUFS_UNSET || data->objset == objset) &&
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   641
	    (data->osname == NULL || (objset_name(objset, osname) == 0 &&
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
   642
	    strcmp(data->osname, osname) == 0)) &&
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   643
	    (data->object == DBUFS_UNSET || data->object == db.db_object) &&
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   644
	    (data->level == DBUFS_UNSET || data->level == level) &&
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   645
	    (data->blkid == DBUFS_UNSET || data->blkid == blkid)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   646
		mdb_printf("%#lr\n", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   647
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   648
	return (WALK_NEXT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   649
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   650
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   651
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   652
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   653
dbufs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   654
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   655
	dbufs_data_t data;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   656
	char *object = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   657
	char *blkid = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   658
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   659
	data.objset = data.object = data.level = data.blkid = DBUFS_UNSET;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   660
	data.osname = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   661
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   662
	if (mdb_getopts(argc, argv,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   663
	    'O', MDB_OPT_UINT64, &data.objset,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   664
	    'n', MDB_OPT_STR, &data.osname,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   665
	    'o', MDB_OPT_STR, &object,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   666
	    'l', MDB_OPT_UINT64, &data.level,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   667
	    'b', MDB_OPT_STR, &blkid) != argc) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   668
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   669
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   670
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   671
	if (object) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   672
		if (strcmp(object, "mdn") == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   673
			data.object = DMU_META_DNODE_OBJECT;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   674
		} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   675
			data.object = mdb_strtoull(object);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   676
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   677
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   678
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   679
	if (blkid) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   680
		if (strcmp(blkid, "bonus") == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   681
			data.blkid = DB_BONUS_BLKID;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   682
		} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   683
			data.blkid = mdb_strtoull(blkid);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   684
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   685
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   686
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   687
	if (mdb_ctf_lookup_by_name("struct dmu_buf_impl", &data.id) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   688
		mdb_warn("couldn't find struct dmu_buf_impl_t");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   689
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   690
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   691
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
   692
	if (mdb_walk("dmu_buf_impl_t", dbufs_cb, &data) != 0) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   693
		mdb_warn("can't walk dbufs");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   694
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   695
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   696
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   697
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   698
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   699
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   700
typedef struct abuf_find_data {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   701
	dva_t dva;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   702
	mdb_ctf_id_t id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   703
} abuf_find_data_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   704
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   705
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   706
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   707
abuf_find_cb(uintptr_t addr, const void *unknown, void *arg)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   708
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   709
	abuf_find_data_t *data = arg;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   710
	dva_t dva;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   711
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   712
	if (GETMEMBID(addr, &data->id, b_dva, dva)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   713
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   714
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   715
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   716
	if (dva.dva_word[0] == data->dva.dva_word[0] &&
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   717
	    dva.dva_word[1] == data->dva.dva_word[1]) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   718
		mdb_printf("%#lr\n", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   719
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   720
	return (WALK_NEXT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   721
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   722
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   723
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   724
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   725
abuf_find(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   726
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   727
	abuf_find_data_t data;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   728
	GElf_Sym sym;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   729
	int i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   730
	const char *syms[] = {
2885
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2459
diff changeset
   731
		"ARC_mru",
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2459
diff changeset
   732
		"ARC_mru_ghost",
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2459
diff changeset
   733
		"ARC_mfu",
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2459
diff changeset
   734
		"ARC_mfu_ghost",
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   735
	};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   736
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   737
	if (argc != 2)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   738
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   739
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   740
	for (i = 0; i < 2; i ++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   741
		switch (argv[i].a_type) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   742
		case MDB_TYPE_STRING:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   743
			data.dva.dva_word[i] = mdb_strtoull(argv[i].a_un.a_str);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   744
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   745
		case MDB_TYPE_IMMEDIATE:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   746
			data.dva.dva_word[i] = argv[i].a_un.a_val;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   747
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   748
		default:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   749
			return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   750
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   751
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   752
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   753
	if (mdb_ctf_lookup_by_name("struct arc_buf_hdr", &data.id) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   754
		mdb_warn("couldn't find struct arc_buf_hdr");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   755
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   756
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   757
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   758
	for (i = 0; i < sizeof (syms) / sizeof (syms[0]); i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   759
		if (mdb_lookup_by_name(syms[i], &sym)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   760
			mdb_warn("can't find symbol %s", syms[i]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   761
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   762
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   763
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   764
		if (mdb_pwalk("list", abuf_find_cb, &data, sym.st_value) != 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   765
			mdb_warn("can't walk %s", syms[i]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   766
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   767
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   768
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   769
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   770
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   771
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   772
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   773
void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   774
abuf_help(void)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   775
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   776
	mdb_printf("::abuf_find dva_word[0] dva_word[1]\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   777
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   778
3403
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   779
/*ARGSUSED*/
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   780
static int
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   781
arc_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   782
{
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   783
	kstat_named_t *stats;
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   784
	GElf_Sym sym;
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   785
	int nstats, i, j;
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   786
	uint_t opt_a = FALSE;
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   787
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   788
	/*
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   789
	 * In its default mode, ::arc prints exactly what one would see with
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   790
	 * the legacy "arc::print".  The legacy[] array tracks the order of
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   791
	 * the legacy "arc" structure -- and whether the variable can be found
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   792
	 * in a global variable or within the arc_stats (the default).
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   793
	 */
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   794
	struct {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   795
		const char *name;
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   796
		const char *var;
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   797
	} legacy[] = {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   798
		{ "anon",		"arc_anon" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   799
		{ "mru",		"arc_mru" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   800
		{ "mru_ghost",		"arc_mru_ghost" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   801
		{ "mfu",		"arc_mfu" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   802
		{ "mfu_ghost",		"arc_mfu_ghost" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   803
		{ "size" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   804
		{ "p" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   805
		{ "c" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   806
		{ "c_min" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   807
		{ "c_max" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   808
		{ "hits" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   809
		{ "misses" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   810
		{ "deleted" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   811
		{ "recycle_miss" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   812
		{ "mutex_miss" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   813
		{ "evict_skip" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   814
		{ "hash_elements" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   815
		{ "hash_elements_max" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   816
		{ "hash_collisions" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   817
		{ "hash_chains" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   818
		{ "hash_chain_max" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   819
		{ "no_grow",		"arc_no_grow" },
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   820
		{ NULL }
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   821
	};
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   822
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   823
	if (mdb_lookup_by_name("arc_stats", &sym) == -1) {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   824
		mdb_warn("failed to find 'arc_stats'");
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   825
		return (DCMD_ERR);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   826
	}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   827
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   828
	stats = mdb_zalloc(sym.st_size, UM_SLEEP | UM_GC);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   829
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   830
	if (mdb_vread(stats, sym.st_size, sym.st_value) == -1) {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   831
		mdb_warn("couldn't read 'arc_stats' at %p", sym.st_value);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   832
		return (DCMD_ERR);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   833
	}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   834
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   835
	nstats = sym.st_size / sizeof (kstat_named_t);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   836
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   837
	if (mdb_getopts(argc, argv, 'a',
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   838
	    MDB_OPT_SETBITS, TRUE, &opt_a, NULL) != argc)
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   839
		return (DCMD_USAGE);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   840
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   841
	mdb_printf("{\n");
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   842
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   843
	if (opt_a) {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   844
		for (i = 0; i < nstats; i++) {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   845
			mdb_printf("    %s = 0x%llx\n", stats[i].name,
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   846
			    stats[i].value.ui64);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   847
		}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   848
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   849
		mdb_printf("}\n");
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   850
		return (DCMD_OK);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   851
	}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   852
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   853
	for (i = 0; legacy[i].name != NULL; i++) {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   854
		if (legacy[i].var != NULL) {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   855
			uint64_t buf;
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   856
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   857
			if (mdb_lookup_by_name(legacy[i].var, &sym) == -1) {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   858
				mdb_warn("failed to find '%s'", legacy[i].var);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   859
				return (DCMD_ERR);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   860
			}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   861
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   862
			if (sym.st_size != sizeof (uint64_t) &&
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   863
			    sym.st_size != sizeof (uint32_t)) {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   864
				mdb_warn("expected scalar for legacy "
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   865
				    "variable '%s'\n", legacy[i].var);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   866
				return (DCMD_ERR);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   867
			}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   868
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   869
			if (mdb_vread(&buf, sym.st_size, sym.st_value) == -1) {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   870
				mdb_warn("couldn't read '%s'", legacy[i].var);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   871
				return (DCMD_ERR);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   872
			}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   873
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   874
			mdb_printf("    %s = ", legacy[i].name);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   875
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   876
			if (sym.st_size == sizeof (uint64_t))
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   877
				mdb_printf("%a\n", buf);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   878
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   879
			if (sym.st_size == sizeof (uint32_t))
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   880
				mdb_printf("%d\n", *((uint32_t *)&buf));
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   881
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   882
			continue;
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   883
		}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   884
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   885
		for (j = 0; j < nstats; j++) {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   886
			if (strcmp(legacy[i].name, stats[j].name) != 0)
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   887
				continue;
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   888
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   889
			mdb_printf("    %s = ", stats[j].name);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   890
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   891
			if (stats[j].value.ui64 == 0) {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   892
				/*
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   893
				 * To remain completely output compatible with
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   894
				 * the legacy arc::print, we print 0 not as
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   895
				 * "0x0" but rather 0.
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   896
				 */
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   897
				mdb_printf("0\n");
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   898
			} else {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   899
				mdb_printf("0x%llx\n", stats[j].value.ui64);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   900
			}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   901
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   902
			break;
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   903
		}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   904
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   905
		if (j == nstats) {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   906
			mdb_warn("couldn't find statistic in 'arc_stats' "
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   907
			    "for field '%s'\n", legacy[i].name);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   908
		}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   909
	}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   910
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   911
	mdb_printf("}\n");
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   912
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   913
	return (DCMD_OK);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   914
}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   915
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   916
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   917
 * ::spa
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   918
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   919
 * 	-c	Print configuration information as well
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   920
 * 	-v	Print vdev state
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   921
 * 	-e	Print vdev error stats
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   922
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   923
 * Print a summarized spa_t.  When given no arguments, prints out a table of all
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   924
 * active pools on the system.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   925
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   926
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   927
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   928
spa_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   929
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   930
	spa_t spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   931
	char poolname[MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   932
	const char *statetab[] = { "ACTIVE", "EXPORTED", "DESTROYED",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   933
		"UNINIT", "UNAVAIL" };
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   934
	const char *state;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   935
	int config = FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   936
	int vdevs = FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   937
	int errors = FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   938
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   939
	if (mdb_getopts(argc, argv,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   940
	    'c', MDB_OPT_SETBITS, TRUE, &config,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   941
	    'v', MDB_OPT_SETBITS, TRUE, &vdevs,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   942
	    'e', MDB_OPT_SETBITS, TRUE, &errors,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   943
	    NULL) != argc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   944
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   945
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   946
	if (!(flags & DCMD_ADDRSPEC)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   947
		if (mdb_walk_dcmd("spa", "spa", argc, argv) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   948
			mdb_warn("can't walk spa");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   949
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   950
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   951
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   952
		return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   953
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   954
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   955
	if (flags & DCMD_PIPE_OUT) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   956
		mdb_printf("%#lr\n", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   957
		return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   958
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   959
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   960
	if (DCMD_HDRSPEC(flags))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   961
		mdb_printf("%<u>%-?s %9s %-*s%</u>\n", "ADDR", "STATE",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   962
		    sizeof (uintptr_t) == 4 ? 60 : 52, "NAME");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   963
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   964
	if (mdb_vread(&spa, sizeof (spa), addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   965
		mdb_warn("failed to read spa_t at %p", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   966
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   967
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   968
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   969
	if (mdb_readstr(poolname, sizeof (poolname), (uintptr_t)spa.spa_name)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   970
	    == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   971
		mdb_warn("failed to read pool name at %p", spa.spa_name);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   972
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   973
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   974
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   975
	if (spa.spa_state < 0 || spa.spa_state > POOL_STATE_UNAVAIL)
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 952
diff changeset
   976
		state = "UNKNOWN";
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   977
	else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   978
		state = statetab[spa.spa_state];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   979
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   980
	mdb_printf("%0?p %9s %s\n", addr, state, poolname);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   981
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   982
	if (config) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   983
		mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   984
		mdb_inc_indent(4);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   985
		if (mdb_call_dcmd("spa_config", addr, flags, 0,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   986
		    NULL) != DCMD_OK)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   987
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   988
		mdb_dec_indent(4);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   989
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   990
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   991
	if (vdevs || errors) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   992
		mdb_arg_t v;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   993
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   994
		v.a_type = MDB_TYPE_STRING;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   995
		v.a_un.a_str = "-e";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   996
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   997
		mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   998
		mdb_inc_indent(4);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   999
		if (mdb_call_dcmd("spa_vdevs", addr, flags, errors ? 1 : 0,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1000
		    &v) != DCMD_OK)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1001
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1002
		mdb_dec_indent(4);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1003
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1004
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1005
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1006
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1007
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1008
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1009
 * ::spa_config
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1010
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1011
 * Given a spa_t, print the configuration information stored in spa_config.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1012
 * Since it's just an nvlist, format it as an indented list of name=value pairs.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1013
 * We simply read the value of spa_config and pass off to ::nvlist.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1014
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1015
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1016
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1017
spa_print_config(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1018
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1019
	spa_t spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1020
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1021
	if (argc != 0 || !(flags & DCMD_ADDRSPEC))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1022
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1023
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1024
	if (mdb_vread(&spa, sizeof (spa), addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1025
		mdb_warn("failed to read spa_t at %p", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1026
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1027
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1028
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1029
	if (spa.spa_config == NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1030
		mdb_printf("(none)\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1031
		return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1032
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1033
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1034
	return (mdb_call_dcmd("nvlist", (uintptr_t)spa.spa_config, flags,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1035
	    0, NULL));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1036
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1037
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1038
void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1039
vdev_help(void)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1040
{
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
  1041
	mdb_printf("[vdev_t*]::vdev [-er]\n"
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1042
	    "\t-> -e display vdev stats\n"
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1043
	    "\t-> -r recursive (visit all children)\n");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1044
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1045
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1046
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1047
 * ::vdev
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1048
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1049
 * Print out a summarized vdev_t, in the following form:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1050
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1051
 * ADDR             STATE	AUX            DESC
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1052
 * fffffffbcde23df0 HEALTHY	-              /dev/dsk/c0t0d0
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1053
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1054
 * If '-r' is specified, recursively visit all children.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1055
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1056
 * With '-e', the statistics associated with the vdev are printed as well.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1057
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1058
static int
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
  1059
do_print_vdev(uintptr_t addr, int flags, int depth, int stats,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1060
    int recursive)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1061
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1062
	vdev_t vdev;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1063
	char desc[MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1064
	int c, children;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1065
	uintptr_t *child;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1066
	const char *state, *aux;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1067
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1068
	if (mdb_vread(&vdev, sizeof (vdev), (uintptr_t)addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1069
		mdb_warn("failed to read vdev_t at %p\n", (uintptr_t)addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1070
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1071
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1072
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1073
	if (flags & DCMD_PIPE_OUT) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1074
		mdb_printf("%#lr", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1075
	} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1076
		if (vdev.vdev_path != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1077
			if (mdb_readstr(desc, sizeof (desc),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1078
			    (uintptr_t)vdev.vdev_path) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1079
				mdb_warn("failed to read vdev_path at %p\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1080
				    vdev.vdev_path);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1081
				return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1082
			}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1083
		} else if (vdev.vdev_ops != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1084
			vdev_ops_t ops;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1085
			if (mdb_vread(&ops, sizeof (ops),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1086
			    (uintptr_t)vdev.vdev_ops) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1087
				mdb_warn("failed to read vdev_ops at %p\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1088
				    vdev.vdev_ops);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1089
				return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1090
			}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1091
			(void) strcpy(desc, ops.vdev_op_type);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1092
		} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1093
			(void) strcpy(desc, "<unknown>");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1094
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1095
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1096
		if (depth == 0 && DCMD_HDRSPEC(flags))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1097
			mdb_printf("%<u>%-?s %-9s %-12s %-*s%</u>\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1098
			    "ADDR", "STATE", "AUX",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1099
			    sizeof (uintptr_t) == 4 ? 43 : 35,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1100
			    "DESCRIPTION");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1101
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1102
		mdb_printf("%0?p ", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1103
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1104
		switch (vdev.vdev_state) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1105
		case VDEV_STATE_CLOSED:
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1106
			state = "CLOSED";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1107
			break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1108
		case VDEV_STATE_OFFLINE:
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1109
			state = "OFFLINE";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1110
			break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1111
		case VDEV_STATE_CANT_OPEN:
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1112
			state = "CANT_OPEN";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1113
			break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1114
		case VDEV_STATE_DEGRADED:
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1115
			state = "DEGRADED";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1116
			break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1117
		case VDEV_STATE_HEALTHY:
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1118
			state = "HEALTHY";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1119
			break;
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4217
diff changeset
  1120
		case VDEV_STATE_REMOVED:
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4217
diff changeset
  1121
			state = "REMOVED";
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4217
diff changeset
  1122
			break;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4217
diff changeset
  1123
		case VDEV_STATE_FAULTED:
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4217
diff changeset
  1124
			state = "FAULTED";
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4217
diff changeset
  1125
			break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1126
		default:
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1127
			state = "UNKNOWN";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1128
			break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1129
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1130
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1131
		switch (vdev.vdev_stat.vs_aux) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1132
		case VDEV_AUX_NONE:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1133
			aux = "-";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1134
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1135
		case VDEV_AUX_OPEN_FAILED:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1136
			aux = "OPEN_FAILED";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1137
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1138
		case VDEV_AUX_CORRUPT_DATA:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1139
			aux = "CORRUPT_DATA";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1140
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1141
		case VDEV_AUX_NO_REPLICAS:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1142
			aux = "NO_REPLICAS";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1143
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1144
		case VDEV_AUX_BAD_GUID_SUM:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1145
			aux = "BAD_GUID_SUM";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1146
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1147
		case VDEV_AUX_TOO_SMALL:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1148
			aux = "TOO_SMALL";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1149
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1150
		case VDEV_AUX_BAD_LABEL:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1151
			aux = "BAD_LABEL";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1152
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1153
		default:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1154
			aux = "UNKNOWN";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1155
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1156
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1157
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1158
		mdb_printf("%-9s %-12s %*s%s\n", state, aux, depth, "", desc);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1159
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1160
		if (stats) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1161
			vdev_stat_t *vs = &vdev.vdev_stat;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1162
			int i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1163
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1164
			mdb_inc_indent(4);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1165
			mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1166
			mdb_printf("%<u>       %12s %12s %12s %12s "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1167
			    "%12s%</u>\n", "READ", "WRITE", "FREE", "CLAIM",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1168
			    "IOCTL");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1169
			mdb_printf("OPS     ");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1170
			for (i = 1; i < ZIO_TYPES; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1171
				mdb_printf("%11#llx%s", vs->vs_ops[i],
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1172
				    i == ZIO_TYPES - 1 ? "" : "  ");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1173
			mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1174
			mdb_printf("BYTES   ");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1175
			for (i = 1; i < ZIO_TYPES; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1176
				mdb_printf("%11#llx%s", vs->vs_bytes[i],
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1177
				    i == ZIO_TYPES - 1 ? "" : "  ");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1178
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1179
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1180
			mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1181
			mdb_printf("EREAD    %10#llx\n", vs->vs_read_errors);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1182
			mdb_printf("EWRITE   %10#llx\n", vs->vs_write_errors);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1183
			mdb_printf("ECKSUM   %10#llx\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1184
			    vs->vs_checksum_errors);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1185
			mdb_dec_indent(4);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1186
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1187
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
  1188
		if (stats)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1189
			mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1190
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1191
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1192
	children = vdev.vdev_children;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1193
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1194
	if (children == 0 || !recursive)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1195
		return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1196
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1197
	child = mdb_alloc(children * sizeof (void *), UM_SLEEP | UM_GC);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1198
	if (mdb_vread(child, children * sizeof (void *),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1199
	    (uintptr_t)vdev.vdev_child) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1200
		mdb_warn("failed to read vdev children at %p", vdev.vdev_child);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1201
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1202
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1203
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1204
	for (c = 0; c < children; c++) {
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
  1205
		if (do_print_vdev(child[c], flags, depth + 2, stats,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1206
		    recursive))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1207
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1208
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1209
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1210
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1211
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1212
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1213
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1214
vdev_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1215
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1216
	int recursive = FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1217
	int stats = FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1218
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1219
	if (mdb_getopts(argc, argv,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1220
	    'r', MDB_OPT_SETBITS, TRUE, &recursive,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1221
	    'e', MDB_OPT_SETBITS, TRUE, &stats,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1222
	    NULL) != argc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1223
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1224
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1225
	if (!(flags & DCMD_ADDRSPEC)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1226
		mdb_warn("no vdev_t address given\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1227
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1228
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1229
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
  1230
	return (do_print_vdev(addr, flags, 0, stats, recursive));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1231
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1232
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1233
typedef struct metaslab_walk_data {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1234
	uint64_t mw_numvdevs;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1235
	uintptr_t *mw_vdevs;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1236
	int mw_curvdev;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1237
	uint64_t mw_nummss;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1238
	uintptr_t *mw_mss;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1239
	int mw_curms;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1240
} metaslab_walk_data_t;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1241
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1242
static int
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1243
metaslab_walk_step(mdb_walk_state_t *wsp)
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1244
{
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1245
	metaslab_walk_data_t *mw = wsp->walk_data;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1246
	metaslab_t ms;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1247
	uintptr_t msp;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1248
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1249
	if (mw->mw_curvdev >= mw->mw_numvdevs)
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1250
		return (WALK_DONE);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1251
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1252
	if (mw->mw_mss == NULL) {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1253
		uintptr_t mssp;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1254
		uintptr_t vdevp;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1255
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1256
		ASSERT(mw->mw_curms == 0);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1257
		ASSERT(mw->mw_nummss == 0);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1258
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1259
		vdevp = mw->mw_vdevs[mw->mw_curvdev];
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1260
		if (GETMEMB(vdevp, struct vdev, vdev_ms, mssp) ||
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1261
		    GETMEMB(vdevp, struct vdev, vdev_ms_count, mw->mw_nummss)) {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1262
			return (WALK_ERR);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1263
		}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1264
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1265
		mw->mw_mss = mdb_alloc(mw->mw_nummss * sizeof (void*),
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1266
		    UM_SLEEP | UM_GC);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1267
		if (mdb_vread(mw->mw_mss, mw->mw_nummss * sizeof (void*),
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1268
		    mssp) == -1) {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1269
			mdb_warn("failed to read vdev_ms at %p", mssp);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1270
			return (WALK_ERR);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1271
		}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1272
	}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1273
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1274
	if (mw->mw_curms >= mw->mw_nummss) {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1275
		mw->mw_mss = NULL;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1276
		mw->mw_curms = 0;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1277
		mw->mw_nummss = 0;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1278
		mw->mw_curvdev++;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1279
		return (WALK_NEXT);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1280
	}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1281
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1282
	msp = mw->mw_mss[mw->mw_curms];
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1283
	if (mdb_vread(&ms, sizeof (metaslab_t), msp) == -1) {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1284
		mdb_warn("failed to read metaslab_t at %p", msp);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1285
		return (WALK_ERR);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1286
	}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1287
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1288
	mw->mw_curms++;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1289
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1290
	return (wsp->walk_callback(msp, &ms, wsp->walk_cbdata));
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1291
}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1292
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1293
/* ARGSUSED */
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1294
static int
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1295
metaslab_walk_init(mdb_walk_state_t *wsp)
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1296
{
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1297
	metaslab_walk_data_t *mw;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1298
	uintptr_t root_vdevp;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1299
	uintptr_t childp;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1300
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1301
	if (wsp->walk_addr == NULL) {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1302
		mdb_warn("must supply address of spa_t\n");
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1303
		return (WALK_ERR);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1304
	}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1305
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1306
	mw = mdb_zalloc(sizeof (metaslab_walk_data_t), UM_SLEEP | UM_GC);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1307
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1308
	if (GETMEMB(wsp->walk_addr, struct spa, spa_root_vdev, root_vdevp) ||
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1309
	    GETMEMB(root_vdevp, struct vdev, vdev_children, mw->mw_numvdevs) ||
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1310
	    GETMEMB(root_vdevp, struct vdev, vdev_child, childp)) {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1311
		return (DCMD_ERR);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1312
	}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1313
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1314
	mw->mw_vdevs = mdb_alloc(mw->mw_numvdevs * sizeof (void *),
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1315
	    UM_SLEEP | UM_GC);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1316
	if (mdb_vread(mw->mw_vdevs, mw->mw_numvdevs * sizeof (void *),
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1317
	    childp) == -1) {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1318
		mdb_warn("failed to read root vdev children at %p", childp);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1319
		return (DCMD_ERR);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1320
	}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1321
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1322
	wsp->walk_data = mw;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1323
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1324
	return (WALK_NEXT);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1325
}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1326
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1327
typedef struct mdb_spa {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1328
	uintptr_t spa_dsl_pool;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1329
	uintptr_t spa_root_vdev;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1330
} mdb_spa_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1331
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1332
typedef struct mdb_dsl_dir {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1333
	uintptr_t dd_phys;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1334
	uint64_t dd_used_bytes;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1335
	int64_t dd_space_towrite[TXG_SIZE];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1336
} mdb_dsl_dir_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1337
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1338
typedef struct mdb_dsl_dir_phys {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1339
	uint64_t dd_used_bytes;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1340
	uint64_t dd_compressed_bytes;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1341
	uint64_t dd_uncompressed_bytes;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1342
} mdb_dsl_dir_phys_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1343
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1344
typedef struct mdb_vdev {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1345
	uintptr_t vdev_parent;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1346
	uintptr_t vdev_ms;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1347
	uint64_t vdev_ms_count;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1348
	vdev_stat_t vdev_stat;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1349
} mdb_vdev_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1350
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1351
typedef struct mdb_metaslab {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1352
	space_map_t ms_allocmap[TXG_SIZE];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1353
	space_map_t ms_freemap[TXG_SIZE];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1354
	space_map_t ms_map;
1732
9e3ae798af31 6280668 pluggable block allocation policy
bonwick
parents: 1544
diff changeset
  1355
	space_map_obj_t ms_smo;
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1356
	space_map_obj_t ms_smo_syncing;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1357
} mdb_metaslab_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1358
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1359
typedef struct space_data {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1360
	uint64_t ms_allocmap[TXG_SIZE];
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1361
	uint64_t ms_freemap[TXG_SIZE];
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1362
	uint64_t ms_map;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1363
	uint64_t avail;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1364
	uint64_t nowavail;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1365
} space_data_t;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1366
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1367
/* ARGSUSED */
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1368
static int
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1369
space_cb(uintptr_t addr, const void *unknown, void *arg)
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1370
{
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1371
	space_data_t *sd = arg;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1372
	mdb_metaslab_t ms;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1373
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1374
	if (GETMEMB(addr, struct metaslab, ms_allocmap, ms.ms_allocmap) ||
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1375
	    GETMEMB(addr, struct metaslab, ms_freemap, ms.ms_freemap) ||
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1376
	    GETMEMB(addr, struct metaslab, ms_map, ms.ms_map) ||
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1377
	    GETMEMB(addr, struct metaslab, ms_smo, ms.ms_smo) ||
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1378
	    GETMEMB(addr, struct metaslab, ms_smo_syncing, ms.ms_smo_syncing)) {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1379
		return (WALK_ERR);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1380
	}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1381
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1382
	sd->ms_allocmap[0] += ms.ms_allocmap[0].sm_space;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1383
	sd->ms_allocmap[1] += ms.ms_allocmap[1].sm_space;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1384
	sd->ms_allocmap[2] += ms.ms_allocmap[2].sm_space;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1385
	sd->ms_allocmap[3] += ms.ms_allocmap[3].sm_space;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1386
	sd->ms_freemap[0] += ms.ms_freemap[0].sm_space;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1387
	sd->ms_freemap[1] += ms.ms_freemap[1].sm_space;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1388
	sd->ms_freemap[2] += ms.ms_freemap[2].sm_space;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1389
	sd->ms_freemap[3] += ms.ms_freemap[3].sm_space;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1390
	sd->ms_map += ms.ms_map.sm_space;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1391
	sd->avail += ms.ms_map.sm_size - ms.ms_smo.smo_alloc;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1392
	sd->nowavail += ms.ms_map.sm_size - ms.ms_smo_syncing.smo_alloc;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1393
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1394
	return (WALK_NEXT);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1395
}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1396
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1397
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1398
 * ::spa_space [-b]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1399
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1400
 * Given a spa_t, print out it's on-disk space usage and in-core
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1401
 * estimates of future usage.  If -b is given, print space in bytes.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1402
 * Otherwise print in megabytes.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1403
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1404
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1405
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1406
spa_space(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1407
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1408
	mdb_spa_t spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1409
	uintptr_t dp_root_dir;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1410
	mdb_dsl_dir_t dd;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1411
	mdb_dsl_dir_phys_t dsp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1412
	uint64_t children;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1413
	uintptr_t childaddr;
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1414
	space_data_t sd;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1415
	int shift = 20;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1416
	char *suffix = "M";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1417
	int bits = FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1418
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1419
	if (mdb_getopts(argc, argv, 'b', MDB_OPT_SETBITS, TRUE, &bits, NULL) !=
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1420
	    argc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1421
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1422
	if (!(flags & DCMD_ADDRSPEC))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1423
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1424
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1425
	if (bits) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1426
		shift = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1427
		suffix = "";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1428
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1429
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1430
	if (GETMEMB(addr, struct spa, spa_dsl_pool, spa.spa_dsl_pool) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1431
	    GETMEMB(addr, struct spa, spa_root_vdev, spa.spa_root_vdev) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1432
	    GETMEMB(spa.spa_root_vdev, struct vdev, vdev_children, children) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1433
	    GETMEMB(spa.spa_root_vdev, struct vdev, vdev_child, childaddr) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1434
	    GETMEMB(spa.spa_dsl_pool, struct dsl_pool,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1435
	    dp_root_dir, dp_root_dir) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1436
	    GETMEMB(dp_root_dir, struct dsl_dir, dd_phys, dd.dd_phys) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1437
	    GETMEMB(dp_root_dir, struct dsl_dir,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1438
	    dd_used_bytes, dd.dd_used_bytes) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1439
	    GETMEMB(dp_root_dir, struct dsl_dir,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1440
	    dd_space_towrite, dd.dd_space_towrite) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1441
	    GETMEMB(dd.dd_phys, struct dsl_dir_phys,
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1442
	    dd_used_bytes, dsp.dd_used_bytes) ||
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1443
	    GETMEMB(dd.dd_phys, struct dsl_dir_phys,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1444
	    dd_compressed_bytes, dsp.dd_compressed_bytes) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1445
	    GETMEMB(dd.dd_phys, struct dsl_dir_phys,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1446
	    dd_uncompressed_bytes, dsp.dd_uncompressed_bytes)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1447
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1448
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1449
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1450
	mdb_printf("dd_space_towrite = %llu%s %llu%s %llu%s %llu%s\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1451
	    dd.dd_space_towrite[0] >> shift, suffix,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1452
	    dd.dd_space_towrite[1] >> shift, suffix,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1453
	    dd.dd_space_towrite[2] >> shift, suffix,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1454
	    dd.dd_space_towrite[3] >> shift, suffix);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1455
	mdb_printf("dd_used_bytes = %llu%s\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1456
	    dd.dd_used_bytes >> shift, suffix);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1457
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1458
	mdb_printf("dd_phys.dd_used_bytes = %llu%s\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1459
	    dsp.dd_used_bytes >> shift, suffix);
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1460
	mdb_printf("dd_phys.dd_compressed_bytes = %llu%s\n",
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1461
	    dsp.dd_compressed_bytes >> shift, suffix);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1462
	mdb_printf("dd_phys.dd_uncompressed_bytes = %llu%s\n",
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1463
	    dsp.dd_uncompressed_bytes >> shift, suffix);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1464
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1465
	bzero(&sd, sizeof (sd));
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1466
	if (mdb_pwalk("metaslab", space_cb, &sd, addr) != 0) {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1467
		mdb_warn("can't walk metaslabs");
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1468
		return (DCMD_ERR);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1469
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1470
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1471
	mdb_printf("ms_allocmap = %llu%s %llu%s %llu%s %llu%s\n",
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1472
	    sd.ms_allocmap[0] >> shift, suffix,
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1473
	    sd.ms_allocmap[1] >> shift, suffix,
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1474
	    sd.ms_allocmap[2] >> shift, suffix,
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1475
	    sd.ms_allocmap[3] >> shift, suffix);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1476
	mdb_printf("ms_freemap = %llu%s %llu%s %llu%s %llu%s\n",
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1477
	    sd.ms_freemap[0] >> shift, suffix,
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1478
	    sd.ms_freemap[1] >> shift, suffix,
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1479
	    sd.ms_freemap[2] >> shift, suffix,
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1480
	    sd.ms_freemap[3] >> shift, suffix);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1481
	mdb_printf("ms_map = %llu%s\n", sd.ms_map >> shift, suffix);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1482
	mdb_printf("last synced avail = %llu%s\n", sd.avail >> shift, suffix);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1483
	mdb_printf("current syncing avail = %llu%s\n",
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1484
	    sd.nowavail >> shift, suffix);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1485
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1486
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1487
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1488
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1489
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1490
 * ::spa_verify
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1491
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1492
 * Given a spa_t, verify that that the pool is self-consistent.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1493
 * Currently, it only checks to make sure that the vdev tree exists.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1494
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1495
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1496
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1497
spa_verify(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1498
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1499
	spa_t spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1500
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1501
	if (argc != 0 || !(flags & DCMD_ADDRSPEC))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1502
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1503
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1504
	if (mdb_vread(&spa, sizeof (spa), addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1505
		mdb_warn("failed to read spa_t at %p", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1506
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1507
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1508
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1509
	if (spa.spa_root_vdev == NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1510
		mdb_printf("no vdev tree present\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1511
		return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1512
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1513
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1514
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1515
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1516
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1517
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1518
 * ::spa_vdevs
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1519
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1520
 * 	-e	Include error stats
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1521
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1522
 * Print out a summarized list of vdevs for the given spa_t.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1523
 * This is accomplished by invoking "::vdev -re" on the root vdev.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1524
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1525
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1526
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1527
spa_vdevs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1528
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1529
	spa_t spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1530
	mdb_arg_t v;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1531
	int errors = FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1532
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1533
	if (mdb_getopts(argc, argv,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1534
	    'e', MDB_OPT_SETBITS, TRUE, &errors,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1535
	    NULL) != argc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1536
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1537
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1538
	if (!(flags & DCMD_ADDRSPEC))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1539
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1540
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1541
	if (mdb_vread(&spa, sizeof (spa), addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1542
		mdb_warn("failed to read spa_t at %p", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1543
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1544
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1545
952
12ec54aa046e 6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents: 789
diff changeset
  1546
	/*
12ec54aa046e 6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents: 789
diff changeset
  1547
	 * Unitialized spa_t structures can have a NULL root vdev.
12ec54aa046e 6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents: 789
diff changeset
  1548
	 */
12ec54aa046e 6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents: 789
diff changeset
  1549
	if (spa.spa_root_vdev == NULL) {
12ec54aa046e 6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents: 789
diff changeset
  1550
		mdb_printf("no associated vdevs\n");
12ec54aa046e 6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents: 789
diff changeset
  1551
		return (DCMD_OK);
12ec54aa046e 6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents: 789
diff changeset
  1552
	}
12ec54aa046e 6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents: 789
diff changeset
  1553
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1554
	v.a_type = MDB_TYPE_STRING;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1555
	v.a_un.a_str = errors ? "-re" : "-r";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1556
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1557
	return (mdb_call_dcmd("vdev", (uintptr_t)spa.spa_root_vdev,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1558
	    flags, 1, &v));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1559
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1560
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1561
/*
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1562
 * ::zio
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1563
 *
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1564
 * Print a summary of zio_t and all its children.  This is intended to display a
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1565
 * zio tree, and hence we only pick the most important pieces of information for
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1566
 * the main summary.  More detailed information can always be found by doing a
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1567
 * '::print zio' on the underlying zio_t.  The columns we display are:
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1568
 *
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1569
 *	ADDRESS		TYPE	STAGE		WAITER
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1570
 *
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1571
 * The 'address' column is indented by one space for each depth level as we
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1572
 * descend down the tree.
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1573
 */
4217
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1574
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1575
#define	ZIO_MAXDEPTH	16
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1576
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1577
static int
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1578
zio_print_cb(uintptr_t addr, const void *data, void *priv)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1579
{
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1580
	const zio_t *zio = data;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1581
	uintptr_t depth = (uintptr_t)priv;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1582
	mdb_ctf_id_t type_enum, stage_enum;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1583
	const char *type, *stage;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1584
	int maxdepth;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1585
4217
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1586
	maxdepth = sizeof (uintptr_t) * 2 + ZIO_MAXDEPTH;
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1587
	if (depth > ZIO_MAXDEPTH)
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1588
		depth = ZIO_MAXDEPTH;
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1589
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1590
	if (mdb_ctf_lookup_by_name("enum zio_type", &type_enum) == -1 ||
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1591
	    mdb_ctf_lookup_by_name("enum zio_stage", &stage_enum) == -1) {
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1592
		mdb_warn("failed to lookup zio enums");
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1593
		return (WALK_ERR);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1594
	}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1595
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1596
	if ((type = mdb_ctf_enum_name(type_enum, zio->io_type)) != NULL)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1597
		type += sizeof ("ZIO_TYPE_") - 1;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1598
	else
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1599
		type = "?";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1600
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1601
	if ((stage = mdb_ctf_enum_name(stage_enum, zio->io_stage)) != NULL)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1602
		stage += sizeof ("ZIO_STAGE_") - 1;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1603
	else
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1604
		stage = "?";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1605
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1606
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1607
	mdb_printf("%*s%-*p %-5s %-22s ",
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1608
	    depth, "", maxdepth - depth, addr, type, stage);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1609
	if (zio->io_waiter)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1610
		mdb_printf("%?p\n", zio->io_waiter);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1611
	else
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1612
		mdb_printf("-\n");
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1613
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1614
	if (mdb_pwalk("zio_child", zio_print_cb, (void *)(depth + 1),
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1615
	    addr) !=  0) {
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1616
		mdb_warn("failed to walk zio_t children at %p\n", addr);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1617
		return (WALK_ERR);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1618
	}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1619
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1620
	return (WALK_NEXT);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1621
}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1622
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1623
/*ARGSUSED*/
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1624
static int
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1625
zio_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1626
{
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1627
	zio_t zio;
4217
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1628
	int maxdepth;
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1629
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1630
	maxdepth = sizeof (uintptr_t) * 2 + ZIO_MAXDEPTH;
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1631
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1632
	if (!(flags & DCMD_ADDRSPEC))
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1633
		return (DCMD_USAGE);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1634
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1635
	if (mdb_vread(&zio, sizeof (zio_t), addr) == -1) {
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1636
		mdb_warn("failed to read zio_t at %p", addr);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1637
		return (DCMD_ERR);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1638
	}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1639
4217
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1640
	if (DCMD_HDRSPEC(flags))
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1641
		mdb_printf("%<u>%-*s %-5s %-22s %-?s%</u>\n", maxdepth,
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1642
		    "ADDRESS", "TYPE", "STAGE", "WAITER");
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1643
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1644
	if (zio_print_cb(addr, &zio, NULL) != WALK_NEXT)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1645
		return (DCMD_ERR);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1646
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1647
	return (DCMD_OK);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1648
}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1649
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1650
/*
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1651
 * [addr]::zio_state
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1652
 *
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1653
 * Print a summary of all zio_t structures on the system, or for a particular
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1654
 * pool.  This is equivalent to '::walk zio_root | ::zio'.
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1655
 */
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1656
/*ARGSUSED*/
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1657
static int
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1658
zio_state(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1659
{
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1660
	/*
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1661
	 * MDB will remember the last address of the pipeline, so if we don't
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1662
	 * zero this we'll end up trying to walk zio structures for a
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1663
	 * non-existent spa_t.
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1664
	 */
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1665
	if (!(flags & DCMD_ADDRSPEC))
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1666
		addr = 0;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1667
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1668
	return (mdb_pwalk_dcmd("zio_root", "zio", argc, argv, addr));
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1669
}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1670
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1671
typedef struct txg_list_walk_data {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1672
	uintptr_t lw_head[TXG_SIZE];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1673
	int	lw_txgoff;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1674
	int	lw_maxoff;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1675
	size_t	lw_offset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1676
	void	*lw_obj;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1677
} txg_list_walk_data_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1678
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1679
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1680
txg_list_walk_init_common(mdb_walk_state_t *wsp, int txg, int maxoff)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1681
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1682
	txg_list_walk_data_t *lwd;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1683
	txg_list_t list;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1684
	int i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1685
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1686
	lwd = mdb_alloc(sizeof (txg_list_walk_data_t), UM_SLEEP | UM_GC);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1687
	if (mdb_vread(&list, sizeof (txg_list_t), wsp->walk_addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1688
		mdb_warn("failed to read txg_list_t at %#lx", wsp->walk_addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1689
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1690
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1691
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1692
	for (i = 0; i < TXG_SIZE; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1693
		lwd->lw_head[i] = (uintptr_t)list.tl_head[i];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1694
	lwd->lw_offset = list.tl_offset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1695
	lwd->lw_obj = mdb_alloc(lwd->lw_offset + sizeof (txg_node_t),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1696
	    UM_SLEEP | UM_GC);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1697
	lwd->lw_txgoff = txg;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1698
	lwd->lw_maxoff = maxoff;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1699
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1700
	wsp->walk_addr = lwd->lw_head[lwd->lw_txgoff];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1701
	wsp->walk_data = lwd;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1702
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1703
	return (WALK_NEXT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1704
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1705
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1706
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1707
txg_list_walk_init(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1708
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1709
	return (txg_list_walk_init_common(wsp, 0, TXG_SIZE-1));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1710
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1711
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1712
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1713
txg_list0_walk_init(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1714
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1715
	return (txg_list_walk_init_common(wsp, 0, 0));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1716
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1717
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1718
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1719
txg_list1_walk_init(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1720
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1721
	return (txg_list_walk_init_common(wsp, 1, 1));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1722
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1723
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1724
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1725
txg_list2_walk_init(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1726
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1727
	return (txg_list_walk_init_common(wsp, 2, 2));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1728
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1729
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1730
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1731
txg_list3_walk_init(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1732
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1733
	return (txg_list_walk_init_common(wsp, 3, 3));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1734
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1735
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1736
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1737
txg_list_walk_step(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1738
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1739
	txg_list_walk_data_t *lwd = wsp->walk_data;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1740
	uintptr_t addr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1741
	txg_node_t *node;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1742
	int status;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1743
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1744
	while (wsp->walk_addr == NULL && lwd->lw_txgoff < lwd->lw_maxoff) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1745
		lwd->lw_txgoff++;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1746
		wsp->walk_addr = lwd->lw_head[lwd->lw_txgoff];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1747
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1748
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1749
	if (wsp->walk_addr == NULL)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1750
		return (WALK_DONE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1751
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1752
	addr = wsp->walk_addr - lwd->lw_offset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1753
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1754
	if (mdb_vread(lwd->lw_obj,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1755
	    lwd->lw_offset + sizeof (txg_node_t), addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1756
		mdb_warn("failed to read list element at %#lx", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1757
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1758
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1759
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1760
	status = wsp->walk_callback(addr, lwd->lw_obj, wsp->walk_cbdata);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1761
	node = (txg_node_t *)((uintptr_t)lwd->lw_obj + lwd->lw_offset);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1762
	wsp->walk_addr = (uintptr_t)node->tn_next[lwd->lw_txgoff];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1763
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1764
	return (status);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1765
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1766
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1767
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1768
 * ::walk spa
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1769
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1770
 * Walk all named spa_t structures in the namespace.  This is nothing more than
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1771
 * a layered avl walk.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1772
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1773
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1774
spa_walk_init(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1775
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1776
	GElf_Sym sym;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1777
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1778
	if (wsp->walk_addr != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1779
		mdb_warn("spa walk only supports global walks\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1780
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1781
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1782
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1783
	if (mdb_lookup_by_obj(ZFS_OBJ_NAME, "spa_namespace_avl", &sym) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1784
		mdb_warn("failed to find symbol 'spa_namespace_avl'");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1785
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1786
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1787
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1788
	wsp->walk_addr = (uintptr_t)sym.st_value;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1790
	if (mdb_layered_walk("avl", wsp) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1791
		mdb_warn("failed to walk 'avl'\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1792
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1793
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1794
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1795
	return (WALK_NEXT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1796
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1797
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1798
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1799
spa_walk_step(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1800
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1801
	spa_t	spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1802
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1803
	if (mdb_vread(&spa, sizeof (spa), wsp->walk_addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1804
		mdb_warn("failed to read spa_t at %p", wsp->walk_addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1805
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1806
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1807
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1808
	return (wsp->walk_callback(wsp->walk_addr, &spa, wsp->walk_cbdata));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1809
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1810
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1811
/*
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1812
 * [addr]::walk zio
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1813
 *
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1814
 * Walk all active zio_t structures on the system.  This is simply a layered
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1815
 * walk on top of ::walk zio_cache, with the optional ability to limit the
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1816
 * structures to a particular pool.
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1817
 */
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1818
static int
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1819
zio_walk_init(mdb_walk_state_t *wsp)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1820
{
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1821
	wsp->walk_data = (void *)wsp->walk_addr;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1822
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1823
	if (mdb_layered_walk("zio_cache", wsp) == -1) {
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1824
		mdb_warn("failed to walk 'zio_cache'\n");
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1825
		return (WALK_ERR);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1826
	}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1827
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1828
	return (WALK_NEXT);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1829
}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1830
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1831
static int
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1832
zio_walk_step(mdb_walk_state_t *wsp)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1833
{
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1834
	zio_t zio;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1835
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1836
	if (mdb_vread(&zio, sizeof (zio), wsp->walk_addr) == -1) {
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1837
		mdb_warn("failed to read zio_t at %p", wsp->walk_addr);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1838
		return (WALK_ERR);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1839
	}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1840
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1841
	if (wsp->walk_data != NULL && wsp->walk_data != zio.io_spa)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1842
		return (WALK_NEXT);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1843
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1844
	return (wsp->walk_callback(wsp->walk_addr, &zio, wsp->walk_cbdata));
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1845
}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1846
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1847
/*
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1848
 * ::walk zio_child
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1849
 *
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1850
 * Walk the children of a zio_t structure.
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1851
 */
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1852
static int
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1853
zio_child_walk_init(mdb_walk_state_t *wsp)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1854
{
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1855
	zio_t zio;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1856
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1857
	if (wsp->walk_addr == 0) {
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1858
		mdb_warn("::walk zio_child doesn't support global walks\n");
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1859
		return (WALK_ERR);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1860
	}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1861
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1862
	if (mdb_vread(&zio, sizeof (zio), wsp->walk_addr) == -1) {
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1863
		mdb_warn("failed to read zio_t at %p", wsp->walk_addr);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1864
		return (WALK_ERR);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1865
	}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1866
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1867
	wsp->walk_addr = (uintptr_t)zio.io_child;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1868
	return (WALK_NEXT);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1869
}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1870
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1871
static int
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1872
zio_sibling_walk_step(mdb_walk_state_t *wsp)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1873
{
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1874
	zio_t zio;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1875
	int status;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1876
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1877
	if (wsp->walk_addr == NULL)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1878
		return (WALK_DONE);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1879
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1880
	if (mdb_vread(&zio, sizeof (zio), wsp->walk_addr) == -1) {
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1881
		mdb_warn("failed to read zio_t at %p", wsp->walk_addr);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1882
		return (WALK_ERR);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1883
	}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1884
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1885
	status = wsp->walk_callback(wsp->walk_addr, &zio, wsp->walk_cbdata);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1886
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1887
	wsp->walk_addr = (uintptr_t)zio.io_sibling_next;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1888
	return (status);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1889
}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1890
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1891
/*
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1892
 * [addr]::walk zio_root
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1893
 *
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1894
 * Walk only root zio_t structures, optionally for a particular spa_t.
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1895
 */
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1896
static int
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1897
zio_walk_root_step(mdb_walk_state_t *wsp)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1898
{
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1899
	zio_t zio;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1900
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1901
	if (mdb_vread(&zio, sizeof (zio), wsp->walk_addr) == -1) {
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1902
		mdb_warn("failed to read zio_t at %p", wsp->walk_addr);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1903
		return (WALK_ERR);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1904
	}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1905
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1906
	if (wsp->walk_data != NULL && wsp->walk_data != zio.io_spa)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1907
		return (WALK_NEXT);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1908
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1909
	if ((uintptr_t)zio.io_root != wsp->walk_addr)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1910
		return (WALK_NEXT);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1911
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1912
	return (wsp->walk_callback(wsp->walk_addr, &zio, wsp->walk_cbdata));
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1913
}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1914
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1915
/*
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1916
 * MDB module linkage information:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1917
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1918
 * We declare a list of structures describing our dcmds, and a function
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1919
 * named _mdb_init to return a pointer to our module information.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1920
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1921
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1922
static const mdb_dcmd_t dcmds[] = {
3403
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
  1923
	{ "arc", "[-a]", "print ARC variables", arc_print },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1924
	{ "blkptr", ":", "print blkptr_t", blkptr },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1925
	{ "dbuf", ":", "print dmu_buf_impl_t", dbuf },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1926
	{ "dbuf_stats", ":", "dbuf stats", dbuf_stats },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1927
	{ "dbufs",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1928
	"\t[-O objset_t*] [-n objset_name | \"mos\"] [-o object | \"mdn\"] \n"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1929
	"\t[-l level] [-b blkid | \"bonus\"]",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1930
	"find dmu_buf_impl_t's that meet criterion", dbufs },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1931
	{ "abuf_find", "dva_word[0] dva_word[1]",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1932
	"find arc_buf_hdr_t of a specified DVA",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1933
	abuf_find },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1934
	{ "spa", "?[-cv]", "spa_t summary", spa_print },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1935
	{ "spa_config", ":", "print spa_t configuration", spa_print_config },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1936
	{ "spa_verify", ":", "verify spa_t consistency", spa_verify },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1937
	{ "spa_space", ":[-b]", "print spa_t on-disk space usage", spa_space },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1938
	{ "spa_vdevs", ":", "given a spa_t, print vdev summary", spa_vdevs },
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
  1939
	{ "vdev", ":[-re]", "vdev_t summary", vdev_print },
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1940
	{ "zio", ":", "zio_t summary", zio_print },
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1941
	{ "zio_state", "?", "print out all zio_t structures on system or "
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1942
	    "for a particular pool", zio_state },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1943
	{ "zio_pipeline", ":", "decode a zio pipeline", zio_pipeline },
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
  1944
	{ "zfs_params", "", "print zfs tunable parameters", zfs_params },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1945
	{ NULL }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1946
};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1947
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1948
static const mdb_walker_t walkers[] = {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1949
	/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1950
	 * In userland, there is no generic provider of list_t walkers, so we
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1951
	 * need to add it.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1952
	 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1953
#ifndef _KERNEL
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1954
	{ LIST_WALK_NAME, LIST_WALK_DESC,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1955
		list_walk_init, list_walk_step, list_walk_fini },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1956
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1957
	{ "zms_freelist", "walk ZFS metaslab freelist",
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1958
		freelist_walk_init, freelist_walk_step, NULL },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1959
	{ "txg_list", "given any txg_list_t *, walk all entries in all txgs",
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1960
		txg_list_walk_init, txg_list_walk_step, NULL },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1961
	{ "txg_list0", "given any txg_list_t *, walk all entries in txg 0",
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1962
		txg_list0_walk_init, txg_list_walk_step, NULL },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1963
	{ "txg_list1", "given any txg_list_t *, walk all entries in txg 1",
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1964
		txg_list1_walk_init, txg_list_walk_step, NULL },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1965
	{ "txg_list2", "given any txg_list_t *, walk all entries in txg 2",
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1966
		txg_list2_walk_init, txg_list_walk_step, NULL },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1967
	{ "txg_list3", "given any txg_list_t *, walk all entries in txg 3",
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1968
		txg_list3_walk_init, txg_list_walk_step, NULL },
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1969
	{ "zio", "walk all zio structures, optionally for a particular spa_t",
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1970
		zio_walk_init, zio_walk_step, NULL },
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1971
	{ "zio_child", "walk children of a zio_t structure",
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1972
		zio_child_walk_init, zio_sibling_walk_step, NULL },
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1973
	{ "zio_root", "walk all root zio_t structures, optionally for a "
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1974
	    "particular spa_t",
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1975
		zio_walk_init, zio_walk_root_step, NULL },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1976
	{ "spa", "walk all spa_t entries in the namespace",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1977
		spa_walk_init, spa_walk_step, NULL },
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1978
	{ "metaslab", "given a spa_t *, walk all metaslab_t structures",
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1979
		metaslab_walk_init, metaslab_walk_step, NULL },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1980
	{ NULL }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1981
};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1982
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1983
static const mdb_modinfo_t modinfo = {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1984
	MDB_API_VERSION, dcmds, walkers
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1985
};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1986
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1987
const mdb_modinfo_t *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1988
_mdb_init(void)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1989
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1990
	return (&modinfo);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1991
}