usr/src/cmd/mdb/common/modules/zfs/zfs.c
author Shampavman <sham.pavman@nexenta.com>
Fri, 01 Apr 2011 07:53:22 -0700
changeset 13315 23dca344544a
parent 12710 66c9c36f2046
child 13700 2889e2596bd6
permissions -rw-r--r--
694 zfs mdb module didn't hear about zfs_txg_synctime_ms Reviewed by: Albert Lee <[email protected]> Reviewed by: Dan McDonald <[email protected]> Reviewed by: Garrett D'Amore <[email protected]> Approved by: Garrett D'Amore <[email protected]>
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
/*
12294
2a74b443e6b1 PSARC/2010/108 zil synchronicity
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11954
diff changeset
    22
 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
13315
23dca344544a 694 zfs mdb module didn't hear about zfs_txg_synctime_ms
Shampavman <sham.pavman@nexenta.com>
parents: 12710
diff changeset
    23
 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    24
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    25
12294
2a74b443e6b1 PSARC/2010/108 zil synchronicity
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11954
diff changeset
    26
/* Portions Copyright 2010 Robert Milkowski */
2a74b443e6b1 PSARC/2010/108 zil synchronicity
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11954
diff changeset
    27
789
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>
11609
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
    40
#include <sys/zap_leaf.h>
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
    41
#include <sys/zap_impl.h>
10407
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
    42
#include <ctype.h>
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
    43
#include <sys/zfs_acl.h>
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
    44
#include <sys/sa_impl.h>
789
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
11726
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11609
diff changeset
    52
#ifndef _KERNEL
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11609
diff changeset
    53
int aok;
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11609
diff changeset
    54
#endif
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11609
diff changeset
    55
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    56
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    57
getmember(uintptr_t addr, const char *type, mdb_ctf_id_t *idp,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    58
    const char *member, int len, void *buf)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    59
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    60
	mdb_ctf_id_t id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    61
	ulong_t off;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    62
	char name[64];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    63
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    64
	if (idp == NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    65
		if (mdb_ctf_lookup_by_name(type, &id) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    66
			mdb_warn("couldn't find type %s", type);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    67
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    68
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    69
		idp = &id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    70
	} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    71
		type = name;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    72
		mdb_ctf_type_name(*idp, name, sizeof (name));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    73
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    74
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    75
	if (mdb_ctf_offsetof(*idp, member, &off) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    76
		mdb_warn("couldn't find member %s of type %s\n", member, type);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    77
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    78
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    79
	if (off % 8 != 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    80
		mdb_warn("member %s of type %s is unsupported bitfield",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    81
		    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
	off /= 8;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    85
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    86
	if (mdb_vread(buf, len, addr + off) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    87
		mdb_warn("failed to read %s from %s at %p",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    88
		    member, type, addr + off);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    89
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    90
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    91
	/* mdb_warn("read %s from %s at %p+%llx\n", member, type, addr, off); */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    92
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    93
	return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    94
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    95
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    96
#define	GETMEMB(addr, type, member, dest) \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    97
	getmember(addr, #type, NULL, #member, sizeof (dest), &(dest))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    98
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    99
#define	GETMEMBID(addr, ctfid, member, dest) \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   100
	getmember(addr, NULL, ctfid, #member, sizeof (dest), &(dest))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   101
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   102
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   103
getrefcount(uintptr_t addr, mdb_ctf_id_t *id,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   104
    const char *member, uint64_t *rc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   105
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   106
	static int gotid;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   107
	static mdb_ctf_id_t rc_id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   108
	ulong_t off;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   109
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   110
	if (!gotid) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   111
		if (mdb_ctf_lookup_by_name("struct refcount", &rc_id) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   112
			mdb_warn("couldn't find struct refcount");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   113
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   114
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   115
		gotid = TRUE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   116
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   117
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   118
	if (mdb_ctf_offsetof(*id, member, &off) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   119
		char name[64];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   120
		mdb_ctf_type_name(*id, name, sizeof (name));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   121
		mdb_warn("couldn't find member %s of type %s\n", member, name);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   122
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   123
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   124
	off /= 8;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   125
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   126
	return (GETMEMBID(addr + off, &rc_id, rc_count, *rc));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   127
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   128
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   129
static boolean_t
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   130
strisprint(const char *cp)
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   131
{
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   132
	for (; *cp; cp++) {
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   133
		if (!isprint(*cp))
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   134
			return (B_FALSE);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   135
	}
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   136
	return (B_TRUE);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   137
}
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   138
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   139
static int verbose;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   140
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   141
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   142
freelist_walk_init(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   143
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   144
	if (wsp->walk_addr == NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   145
		mdb_warn("must supply starting address\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   146
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   147
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   148
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   149
	wsp->walk_data = 0;  /* Index into the freelist */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   150
	return (WALK_NEXT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   151
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   152
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   153
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   154
freelist_walk_step(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   155
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   156
	uint64_t entry;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   157
	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
   158
	char *ddata[] = { "ALLOC", "FREE", "CONDENSE", "INVALID",
a3d194896a76 6480230 ::walk spa|::walk zms_freelist cause mdb to core dump
ck153898
parents: 3158
diff changeset
   159
			    "INVALID", "INVALID", "INVALID", "INVALID" };
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   160
	int mapshift = SPA_MINBLOCKSHIFT;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   161
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   162
	if (mdb_vread(&entry, sizeof (entry), wsp->walk_addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   163
		mdb_warn("failed to read freelist entry %p", wsp->walk_addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   164
		return (WALK_DONE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   165
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   166
	wsp->walk_addr += sizeof (entry);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   167
	wsp->walk_data = (void *)(number + 1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   168
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   169
	if (SM_DEBUG_DECODE(entry)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   170
		mdb_printf("DEBUG: %3u  %10s: txg=%llu  pass=%llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   171
		    number,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   172
		    ddata[SM_DEBUG_ACTION_DECODE(entry)],
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   173
		    SM_DEBUG_TXG_DECODE(entry),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   174
		    SM_DEBUG_SYNCPASS_DECODE(entry));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   175
	} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   176
		mdb_printf("Entry: %3u  offsets=%08llx-%08llx  type=%c  "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   177
		    "size=%06llx", number,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   178
		    SM_OFFSET_DECODE(entry) << mapshift,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   179
		    (SM_OFFSET_DECODE(entry) + SM_RUN_DECODE(entry)) <<
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   180
		    mapshift,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   181
		    SM_TYPE_DECODE(entry) == SM_ALLOC ? 'A' : 'F',
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   182
		    SM_RUN_DECODE(entry) << mapshift);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   183
		if (verbose)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   184
			mdb_printf("      (raw=%012llx)\n", entry);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   185
		mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   186
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   187
	return (WALK_NEXT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   188
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   189
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   190
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   191
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   192
dataset_name(uintptr_t addr, char *buf)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   193
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   194
	static int gotid;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   195
	static mdb_ctf_id_t dd_id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   196
	uintptr_t dd_parent;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   197
	char dd_myname[MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   198
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   199
	if (!gotid) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   200
		if (mdb_ctf_lookup_by_name("struct dsl_dir",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   201
		    &dd_id) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   202
			mdb_warn("couldn't find struct dsl_dir");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   203
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   204
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   205
		gotid = TRUE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   206
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   207
	if (GETMEMBID(addr, &dd_id, dd_parent, dd_parent) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   208
	    GETMEMBID(addr, &dd_id, dd_myname, dd_myname)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   209
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   210
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   211
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   212
	if (dd_parent) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   213
		if (dataset_name(dd_parent, buf))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   214
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   215
		strcat(buf, "/");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   216
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   217
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   218
	if (dd_myname[0])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   219
		strcat(buf, dd_myname);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   220
	else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   221
		strcat(buf, "???");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   222
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   223
	return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   224
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   225
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   226
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   227
objset_name(uintptr_t addr, char *buf)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   228
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   229
	static int gotid;
11954
d6630fa76b91 6936265 mismerge in zfs mdb module
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
   230
	static mdb_ctf_id_t os_id, ds_id;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   231
	uintptr_t os_dsl_dataset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   232
	char ds_snapname[MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   233
	uintptr_t ds_dir;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   234
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   235
	buf[0] = '\0';
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   236
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   237
	if (!gotid) {
11954
d6630fa76b91 6936265 mismerge in zfs mdb module
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
   238
		if (mdb_ctf_lookup_by_name("struct objset",
d6630fa76b91 6936265 mismerge in zfs mdb module
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
   239
		    &os_id) == -1) {
d6630fa76b91 6936265 mismerge in zfs mdb module
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
   240
			mdb_warn("couldn't find struct objset");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   241
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   242
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   243
		if (mdb_ctf_lookup_by_name("struct dsl_dataset",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   244
		    &ds_id) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   245
			mdb_warn("couldn't find struct dsl_dataset");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   246
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   247
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   248
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   249
		gotid = TRUE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   250
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   251
11954
d6630fa76b91 6936265 mismerge in zfs mdb module
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
   252
	if (GETMEMBID(addr, &os_id, os_dsl_dataset, os_dsl_dataset))
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   253
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   254
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   255
	if (os_dsl_dataset == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   256
		strcat(buf, "mos");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   257
		return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   258
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   259
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   260
	if (GETMEMBID(os_dsl_dataset, &ds_id, ds_snapname, ds_snapname) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   261
	    GETMEMBID(os_dsl_dataset, &ds_id, ds_dir, ds_dir)) {
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
	if (ds_dir && dataset_name(ds_dir, buf))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   266
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   267
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   268
	if (ds_snapname[0]) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   269
		strcat(buf, "@");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   270
		strcat(buf, ds_snapname);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   271
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   272
	return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   273
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   274
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   275
static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   276
enum_lookup(char *out, size_t size, mdb_ctf_id_t id, int val,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   277
    const char *prefix)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   278
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   279
	const char *cp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   280
	size_t len = strlen(prefix);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   281
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   282
	if ((cp = mdb_ctf_enum_name(id, val)) != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   283
		if (strncmp(cp, prefix, len) == 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   284
			cp += len;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   285
		(void) strncpy(out, cp, size);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   286
	} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   287
		mdb_snprintf(out, size, "? (%d)", val);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   288
	}
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
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   292
static int
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   293
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
   294
{
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   295
	/*
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   296
	 * This table can be approximately generated by running:
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   297
	 * 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
   298
	 */
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   299
	static const char *params[] = {
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   300
		"arc_reduce_dnlc_percent",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   301
		"zfs_arc_max",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   302
		"zfs_arc_min",
3158
f30a3849aa23 6493923 nfsfind on ZFS filesystem quickly depletes memory in a 1GB system
maybee
parents: 3059
diff changeset
   303
		"arc_shrink_shift",
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   304
		"zfs_mdcomp_disable",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   305
		"zfs_prefetch_disable",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   306
		"zfetch_max_streams",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   307
		"zfetch_min_sec_reap",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   308
		"zfetch_block_cap",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   309
		"zfetch_array_rd_sz",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   310
		"zfs_default_bs",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   311
		"zfs_default_ibs",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   312
		"metaslab_aliquot",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   313
		"reference_tracking_enable",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   314
		"reference_history",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   315
		"spa_max_replication_override",
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   316
		"spa_mode_global",
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   317
		"zfs_flags",
13315
23dca344544a 694 zfs mdb module didn't hear about zfs_txg_synctime_ms
Shampavman <sham.pavman@nexenta.com>
parents: 12710
diff changeset
   318
		"zfs_txg_synctime_ms",
6245
1a2a7cfb9f26 6429205 each zpool needs to monitor its throughput and throttle heavy writers
maybee
parents: 5367
diff changeset
   319
		"zfs_txg_timeout",
1a2a7cfb9f26 6429205 each zpool needs to monitor its throughput and throttle heavy writers
maybee
parents: 5367
diff changeset
   320
		"zfs_write_limit_min",
1a2a7cfb9f26 6429205 each zpool needs to monitor its throughput and throttle heavy writers
maybee
parents: 5367
diff changeset
   321
		"zfs_write_limit_max",
1a2a7cfb9f26 6429205 each zpool needs to monitor its throughput and throttle heavy writers
maybee
parents: 5367
diff changeset
   322
		"zfs_write_limit_shift",
1a2a7cfb9f26 6429205 each zpool needs to monitor its throughput and throttle heavy writers
maybee
parents: 5367
diff changeset
   323
		"zfs_write_limit_override",
1a2a7cfb9f26 6429205 each zpool needs to monitor its throughput and throttle heavy writers
maybee
parents: 5367
diff changeset
   324
		"zfs_no_write_throttle",
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   325
		"zfs_vdev_cache_max",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   326
		"zfs_vdev_cache_size",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   327
		"zfs_vdev_cache_bshift",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   328
		"vdev_mirror_shift",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   329
		"zfs_vdev_max_pending",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   330
		"zfs_vdev_min_pending",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   331
		"zfs_scrub_limit",
11147
74e8c05021f1 6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents: 10922
diff changeset
   332
		"zfs_no_scrub_io",
74e8c05021f1 6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents: 10922
diff changeset
   333
		"zfs_no_scrub_prefetch",
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   334
		"zfs_vdev_time_shift",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   335
		"zfs_vdev_ramp_rate",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   336
		"zfs_vdev_aggregation_limit",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   337
		"fzap_default_block_shift",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   338
		"zfs_immediate_write_sz",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   339
		"zfs_read_chunk_size",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   340
		"zfs_nocacheflush",
12294
2a74b443e6b1 PSARC/2010/108 zil synchronicity
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11954
diff changeset
   341
		"zil_replay_disable",
6245
1a2a7cfb9f26 6429205 each zpool needs to monitor its throughput and throttle heavy writers
maybee
parents: 5367
diff changeset
   342
		"metaslab_gang_bang",
9480
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 8632
diff changeset
   343
		"metaslab_df_alloc_threshold",
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 8632
diff changeset
   344
		"metaslab_df_free_pct",
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   345
		"zio_injection_enabled",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   346
		"zvol_immediate_write_sz",
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   347
	};
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   348
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   349
	for (int i = 0; i < sizeof (params) / sizeof (params[0]); i++) {
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   350
		int sz;
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   351
		uint64_t val64;
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   352
		uint32_t *val32p = (uint32_t *)&val64;
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   353
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   354
		sz = mdb_readvar(&val64, params[i]);
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   355
		if (sz == 4) {
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   356
			mdb_printf("%s = 0x%x\n", params[i], *val32p);
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   357
		} else if (sz == 8) {
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   358
			mdb_printf("%s = 0x%llx\n", params[i], val64);
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   359
		} else {
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   360
			mdb_warn("variable %s not found", params[i]);
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   361
		}
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   362
	}
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   363
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   364
	return (DCMD_OK);
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   365
}
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   366
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   367
/* ARGSUSED */
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
   368
static int
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   369
blkptr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   370
{
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   371
	mdb_ctf_id_t type_enum, checksum_enum, compress_enum;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   372
	char type[80], checksum[80], compress[80];
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   373
	blkptr_t blk, *bp = &blk;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   374
	char buf[BP_SPRINTF_LEN];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   375
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   376
	if (mdb_vread(&blk, sizeof (blkptr_t), addr) == -1) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   377
		mdb_warn("failed to read blkptr_t");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   378
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   379
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   380
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   381
	if (mdb_ctf_lookup_by_name("enum dmu_object_type", &type_enum) == -1 ||
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   382
	    mdb_ctf_lookup_by_name("enum zio_checksum", &checksum_enum) == -1 ||
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   383
	    mdb_ctf_lookup_by_name("enum zio_compress", &compress_enum) == -1) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   384
		mdb_warn("Could not find blkptr enumerated types");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   385
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   386
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   387
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   388
	enum_lookup(type, sizeof (type), type_enum,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   389
	    BP_GET_TYPE(bp), "DMU_OT_");
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   390
	enum_lookup(checksum, sizeof (checksum), checksum_enum,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   391
	    BP_GET_CHECKSUM(bp), "ZIO_CHECKSUM_");
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   392
	enum_lookup(compress, sizeof (compress), compress_enum,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   393
	    BP_GET_COMPRESS(bp), "ZIO_COMPRESS_");
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   394
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   395
	SPRINTF_BLKPTR(mdb_snprintf, '\n', buf, bp, type, checksum, compress);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   396
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10860
diff changeset
   397
	mdb_printf("%s\n", buf);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   398
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   399
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   400
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   401
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   402
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   403
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   404
dbuf(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   405
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   406
	mdb_ctf_id_t id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   407
	dmu_buf_t db;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   408
	uintptr_t objset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   409
	uint8_t level;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   410
	uint64_t blkid;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   411
	uint64_t holds;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   412
	char objectname[32];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   413
	char blkidname[32];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   414
	char path[MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   415
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   416
	if (DCMD_HDRSPEC(flags)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   417
		mdb_printf("        addr object lvl blkid holds os\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   418
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   419
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   420
	if (mdb_ctf_lookup_by_name("struct dmu_buf_impl", &id) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   421
		mdb_warn("couldn't find struct dmu_buf_impl_t");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   422
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   423
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   424
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   425
	if (GETMEMBID(addr, &id, db_objset, objset) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   426
	    GETMEMBID(addr, &id, db, db) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   427
	    GETMEMBID(addr, &id, db_level, level) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   428
	    GETMEMBID(addr, &id, db_blkid, blkid)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   429
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   430
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   431
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   432
	if (getrefcount(addr, &id, "db_holds", &holds)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   433
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   434
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   435
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   436
	if (db.db_object == DMU_META_DNODE_OBJECT)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   437
		(void) strcpy(objectname, "mdn");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   438
	else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   439
		(void) mdb_snprintf(objectname, sizeof (objectname), "%llx",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   440
		    (u_longlong_t)db.db_object);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   441
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
   442
	if (blkid == DMU_BONUS_BLKID)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   443
		(void) strcpy(blkidname, "bonus");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   444
	else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   445
		(void) mdb_snprintf(blkidname, sizeof (blkidname), "%llx",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   446
		    (u_longlong_t)blkid);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   447
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   448
	if (objset_name(objset, path)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   449
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   450
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   451
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   452
	mdb_printf("%p %8s %1u %9s %2llu %s\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   453
	    addr, objectname, level, blkidname, holds, path);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   454
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   455
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   456
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   457
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   458
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   459
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   460
dbuf_stats(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   461
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   462
#define	HISTOSZ 32
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   463
	uintptr_t dbp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   464
	dmu_buf_impl_t db;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   465
	dbuf_hash_table_t ht;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   466
	uint64_t bucket, ndbufs;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   467
	uint64_t histo[HISTOSZ];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   468
	uint64_t histo2[HISTOSZ];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   469
	int i, maxidx;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   470
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   471
	if (mdb_readvar(&ht, "dbuf_hash_table") == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   472
		mdb_warn("failed to read 'dbuf_hash_table'");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   473
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   474
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   475
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   476
	for (i = 0; i < HISTOSZ; i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   477
		histo[i] = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   478
		histo2[i] = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   479
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   480
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   481
	ndbufs = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   482
	for (bucket = 0; bucket < ht.hash_table_mask+1; bucket++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   483
		int len;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   484
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   485
		if (mdb_vread(&dbp, sizeof (void *),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   486
		    (uintptr_t)(ht.hash_table+bucket)) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   487
			mdb_warn("failed to read hash bucket %u at %p",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   488
			    bucket, ht.hash_table+bucket);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   489
			return (DCMD_ERR);
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
		len = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   493
		while (dbp != 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   494
			if (mdb_vread(&db, sizeof (dmu_buf_impl_t),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   495
			    dbp) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   496
				mdb_warn("failed to read dbuf at %p", dbp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   497
				return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   498
			}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   499
			dbp = (uintptr_t)db.db_hash_next;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   500
			for (i = MIN(len, HISTOSZ - 1); i >= 0; i--)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   501
				histo2[i]++;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   502
			len++;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   503
			ndbufs++;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   504
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   505
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   506
		if (len >= HISTOSZ)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   507
			len = HISTOSZ-1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   508
		histo[len]++;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   509
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   510
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   511
	mdb_printf("hash table has %llu buckets, %llu dbufs "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   512
	    "(avg %llu buckets/dbuf)\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   513
	    ht.hash_table_mask+1, ndbufs,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   514
	    (ht.hash_table_mask+1)/ndbufs);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   515
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   516
	mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   517
	maxidx = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   518
	for (i = 0; i < HISTOSZ; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   519
		if (histo[i] > 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   520
			maxidx = i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   521
	mdb_printf("hash chain length	number of buckets\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   522
	for (i = 0; i <= maxidx; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   523
		mdb_printf("%u			%llu\n", i, histo[i]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   524
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   525
	mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   526
	maxidx = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   527
	for (i = 0; i < HISTOSZ; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   528
		if (histo2[i] > 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   529
			maxidx = i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   530
	mdb_printf("hash chain depth	number of dbufs\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   531
	for (i = 0; i <= maxidx; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   532
		mdb_printf("%u or more		%llu	%llu%%\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   533
		    i, histo2[i], histo2[i]*100/ndbufs);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   534
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   535
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   536
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   537
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   538
11609
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   539
#define	CHAIN_END 0xffff
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   540
/*
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   541
 * ::zap_leaf [-v]
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   542
 *
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   543
 * Print a zap_leaf_phys_t, assumed to be 16k
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   544
 */
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   545
/* ARGSUSED */
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   546
static int
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   547
zap_leaf(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   548
{
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   549
	char buf[16*1024];
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   550
	int verbose = B_FALSE;
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   551
	int four = B_FALSE;
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   552
	zap_leaf_t l;
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   553
	zap_leaf_phys_t *zlp = (void *)buf;
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   554
	int i;
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   555
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   556
	if (mdb_getopts(argc, argv,
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   557
	    'v', MDB_OPT_SETBITS, TRUE, &verbose,
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   558
	    '4', MDB_OPT_SETBITS, TRUE, &four,
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   559
	    NULL) != argc)
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   560
		return (DCMD_USAGE);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   561
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   562
	l.l_phys = zlp;
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   563
	l.l_bs = 14; /* assume 16k blocks */
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   564
	if (four)
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   565
		l.l_bs = 12;
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   566
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   567
	if (!(flags & DCMD_ADDRSPEC)) {
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   568
		return (DCMD_USAGE);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   569
	}
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   570
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   571
	if (mdb_vread(buf, sizeof (buf), addr) == -1) {
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   572
		mdb_warn("failed to read zap_leaf_phys_t at %p", addr);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   573
		return (DCMD_ERR);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   574
	}
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   575
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   576
	if (zlp->l_hdr.lh_block_type != ZBT_LEAF ||
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   577
	    zlp->l_hdr.lh_magic != ZAP_LEAF_MAGIC) {
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   578
		mdb_warn("This does not appear to be a zap_leaf_phys_t");
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   579
		return (DCMD_ERR);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   580
	}
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   581
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   582
	mdb_printf("zap_leaf_phys_t at %p:\n", addr);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   583
	mdb_printf("    lh_prefix_len = %u\n", zlp->l_hdr.lh_prefix_len);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   584
	mdb_printf("    lh_prefix = %llx\n", zlp->l_hdr.lh_prefix);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   585
	mdb_printf("    lh_nentries = %u\n", zlp->l_hdr.lh_nentries);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   586
	mdb_printf("    lh_nfree = %u\n", zlp->l_hdr.lh_nfree,
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   587
	    zlp->l_hdr.lh_nfree * 100 / (ZAP_LEAF_NUMCHUNKS(&l)));
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   588
	mdb_printf("    lh_freelist = %u\n", zlp->l_hdr.lh_freelist);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   589
	mdb_printf("    lh_flags = %x (%s)\n", zlp->l_hdr.lh_flags,
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   590
	    zlp->l_hdr.lh_flags & ZLF_ENTRIES_CDSORTED ?
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   591
	    "ENTRIES_CDSORTED" : "");
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   592
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   593
	if (verbose) {
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   594
		mdb_printf(" hash table:\n");
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   595
		for (i = 0; i < ZAP_LEAF_HASH_NUMENTRIES(&l); i++) {
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   596
			if (zlp->l_hash[i] != CHAIN_END)
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   597
				mdb_printf("    %u: %u\n", i, zlp->l_hash[i]);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   598
		}
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   599
	}
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   600
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   601
	mdb_printf(" chunks:\n");
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   602
	for (i = 0; i < ZAP_LEAF_NUMCHUNKS(&l); i++) {
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   603
		/* LINTED: alignment */
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   604
		zap_leaf_chunk_t *zlc = &ZAP_LEAF_CHUNK(&l, i);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   605
		switch (zlc->l_entry.le_type) {
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   606
		case ZAP_CHUNK_FREE:
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   607
			if (verbose) {
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   608
				mdb_printf("    %u: free; lf_next = %u\n",
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   609
				    i, zlc->l_free.lf_next);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   610
			}
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   611
			break;
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   612
		case ZAP_CHUNK_ENTRY:
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   613
			mdb_printf("    %u: entry\n", i);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   614
			if (verbose) {
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   615
				mdb_printf("        le_next = %u\n",
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   616
				    zlc->l_entry.le_next);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   617
			}
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   618
			mdb_printf("        le_name_chunk = %u\n",
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   619
			    zlc->l_entry.le_name_chunk);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   620
			mdb_printf("        le_name_numints = %u\n",
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   621
			    zlc->l_entry.le_name_numints);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   622
			mdb_printf("        le_value_chunk = %u\n",
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   623
			    zlc->l_entry.le_value_chunk);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   624
			mdb_printf("        le_value_intlen = %u\n",
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   625
			    zlc->l_entry.le_value_intlen);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   626
			mdb_printf("        le_value_numints = %u\n",
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   627
			    zlc->l_entry.le_value_numints);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   628
			mdb_printf("        le_cd = %u\n",
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   629
			    zlc->l_entry.le_cd);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   630
			mdb_printf("        le_hash = %llx\n",
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   631
			    zlc->l_entry.le_hash);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   632
			break;
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   633
		case ZAP_CHUNK_ARRAY:
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   634
			mdb_printf("    %u: array", i);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   635
			if (strisprint((char *)zlc->l_array.la_array))
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   636
				mdb_printf(" \"%s\"", zlc->l_array.la_array);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   637
			mdb_printf("\n");
11609
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   638
			if (verbose) {
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   639
				int j;
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   640
				mdb_printf("        ");
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   641
				for (j = 0; j < ZAP_LEAF_ARRAY_BYTES; j++) {
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   642
					mdb_printf("%02x ",
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   643
					    zlc->l_array.la_array[j]);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   644
				}
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   645
				mdb_printf("\n");
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   646
			}
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   647
			if (zlc->l_array.la_next != CHAIN_END) {
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   648
				mdb_printf("        lf_next = %u\n",
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   649
				    zlc->l_array.la_next);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   650
			}
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   651
			break;
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   652
		default:
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   653
			mdb_printf("    %u: undefined type %u\n",
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   654
			    zlc->l_entry.le_type);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   655
		}
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   656
	}
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   657
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   658
	return (DCMD_OK);
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   659
}
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
   660
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   661
typedef struct dbufs_data {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   662
	mdb_ctf_id_t id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   663
	uint64_t objset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   664
	uint64_t object;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   665
	uint64_t level;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   666
	uint64_t blkid;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   667
	char *osname;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   668
} dbufs_data_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   669
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   670
#define	DBUFS_UNSET	(0xbaddcafedeadbeefULL)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   671
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   672
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   673
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   674
dbufs_cb(uintptr_t addr, const void *unknown, void *arg)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   675
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   676
	dbufs_data_t *data = arg;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   677
	uintptr_t objset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   678
	dmu_buf_t db;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   679
	uint8_t level;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   680
	uint64_t blkid;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   681
	char osname[MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   682
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   683
	if (GETMEMBID(addr, &data->id, db_objset, objset) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   684
	    GETMEMBID(addr, &data->id, db, db) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   685
	    GETMEMBID(addr, &data->id, db_level, level) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   686
	    GETMEMBID(addr, &data->id, db_blkid, blkid)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   687
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   688
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   689
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   690
	if ((data->objset == DBUFS_UNSET || data->objset == objset) &&
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   691
	    (data->osname == NULL || (objset_name(objset, osname) == 0 &&
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
   692
	    strcmp(data->osname, osname) == 0)) &&
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   693
	    (data->object == DBUFS_UNSET || data->object == db.db_object) &&
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   694
	    (data->level == DBUFS_UNSET || data->level == level) &&
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   695
	    (data->blkid == DBUFS_UNSET || data->blkid == blkid)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   696
		mdb_printf("%#lr\n", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   697
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   698
	return (WALK_NEXT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   699
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   700
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   701
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   702
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   703
dbufs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   704
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   705
	dbufs_data_t data;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   706
	char *object = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   707
	char *blkid = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   708
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   709
	data.objset = data.object = data.level = data.blkid = DBUFS_UNSET;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   710
	data.osname = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   711
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   712
	if (mdb_getopts(argc, argv,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   713
	    'O', MDB_OPT_UINT64, &data.objset,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   714
	    'n', MDB_OPT_STR, &data.osname,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   715
	    'o', MDB_OPT_STR, &object,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   716
	    'l', MDB_OPT_UINT64, &data.level,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   717
	    'b', MDB_OPT_STR, &blkid) != argc) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   718
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   719
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   720
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   721
	if (object) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   722
		if (strcmp(object, "mdn") == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   723
			data.object = DMU_META_DNODE_OBJECT;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   724
		} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   725
			data.object = mdb_strtoull(object);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   726
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   727
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   728
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   729
	if (blkid) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   730
		if (strcmp(blkid, "bonus") == 0) {
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
   731
			data.blkid = DMU_BONUS_BLKID;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   732
		} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   733
			data.blkid = mdb_strtoull(blkid);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   734
		}
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 (mdb_ctf_lookup_by_name("struct dmu_buf_impl", &data.id) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   738
		mdb_warn("couldn't find struct dmu_buf_impl_t");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   739
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   740
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   741
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
   742
	if (mdb_walk("dmu_buf_impl_t", dbufs_cb, &data) != 0) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   743
		mdb_warn("can't walk dbufs");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   744
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   745
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   746
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   747
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   748
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   749
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   750
typedef struct abuf_find_data {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   751
	dva_t dva;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   752
	mdb_ctf_id_t id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   753
} abuf_find_data_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   754
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   755
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   756
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   757
abuf_find_cb(uintptr_t addr, const void *unknown, void *arg)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   758
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   759
	abuf_find_data_t *data = arg;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   760
	dva_t dva;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   761
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   762
	if (GETMEMBID(addr, &data->id, b_dva, dva)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   763
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   764
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   765
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   766
	if (dva.dva_word[0] == data->dva.dva_word[0] &&
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   767
	    dva.dva_word[1] == data->dva.dva_word[1]) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   768
		mdb_printf("%#lr\n", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   769
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   770
	return (WALK_NEXT);
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
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   774
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   775
abuf_find(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   776
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   777
	abuf_find_data_t data;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   778
	GElf_Sym sym;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   779
	int i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   780
	const char *syms[] = {
2885
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2459
diff changeset
   781
		"ARC_mru",
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2459
diff changeset
   782
		"ARC_mru_ghost",
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2459
diff changeset
   783
		"ARC_mfu",
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2459
diff changeset
   784
		"ARC_mfu_ghost",
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   785
	};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   786
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   787
	if (argc != 2)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   788
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   790
	for (i = 0; i < 2; i ++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   791
		switch (argv[i].a_type) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   792
		case MDB_TYPE_STRING:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   793
			data.dva.dva_word[i] = mdb_strtoull(argv[i].a_un.a_str);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   794
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   795
		case MDB_TYPE_IMMEDIATE:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   796
			data.dva.dva_word[i] = argv[i].a_un.a_val;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   797
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   798
		default:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   799
			return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   800
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   801
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   802
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   803
	if (mdb_ctf_lookup_by_name("struct arc_buf_hdr", &data.id) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   804
		mdb_warn("couldn't find struct arc_buf_hdr");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   805
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   806
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   807
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   808
	for (i = 0; i < sizeof (syms) / sizeof (syms[0]); i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   809
		if (mdb_lookup_by_name(syms[i], &sym)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   810
			mdb_warn("can't find symbol %s", syms[i]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   811
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   812
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   813
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   814
		if (mdb_pwalk("list", abuf_find_cb, &data, sym.st_value) != 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   815
			mdb_warn("can't walk %s", syms[i]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   816
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   817
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   818
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   819
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   820
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   821
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   822
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   823
/* ARGSUSED */
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   824
static int
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   825
dbgmsg_cb(uintptr_t addr, const void *unknown, void *arg)
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   826
{
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   827
	static mdb_ctf_id_t id;
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   828
	static boolean_t gotid;
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   829
	static ulong_t off;
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   830
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   831
	int *verbosep = arg;
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   832
	time_t timestamp;
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   833
	char buf[1024];
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   834
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   835
	if (!gotid) {
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   836
		if (mdb_ctf_lookup_by_name("struct zfs_dbgmsg", &id) == -1) {
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   837
			mdb_warn("couldn't find struct zfs_dbgmsg");
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   838
			return (WALK_ERR);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   839
		}
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   840
		gotid = TRUE;
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   841
		if (mdb_ctf_offsetof(id, "zdm_msg", &off) == -1) {
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   842
			mdb_warn("couldn't find zdm_msg");
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   843
			return (WALK_ERR);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   844
		}
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   845
		off /= 8;
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   846
	}
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   847
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   848
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   849
	if (GETMEMBID(addr, &id, zdm_timestamp, timestamp)) {
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   850
		return (WALK_ERR);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   851
	}
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   852
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   853
	if (mdb_readstr(buf, sizeof (buf), addr + off) == -1) {
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   854
		mdb_warn("failed to read zdm_msg at %p\n", addr + off);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   855
		return (DCMD_ERR);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   856
	}
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   857
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   858
	if (*verbosep)
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   859
		mdb_printf("%Y ", timestamp);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   860
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   861
	mdb_printf("%s\n", buf);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   862
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   863
	if (*verbosep)
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   864
		(void) mdb_call_dcmd("whatis", addr, DCMD_ADDRSPEC, 0, NULL);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   865
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   866
	return (WALK_NEXT);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   867
}
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   868
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   869
/* ARGSUSED */
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   870
static int
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   871
dbgmsg(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   872
{
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   873
	GElf_Sym sym;
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   874
	int verbose = FALSE;
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   875
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   876
	if (mdb_getopts(argc, argv,
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   877
	    'v', MDB_OPT_SETBITS, TRUE, &verbose,
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   878
	    NULL) != argc)
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   879
		return (DCMD_USAGE);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   880
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   881
	if (mdb_lookup_by_name("zfs_dbgmsgs", &sym)) {
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   882
		mdb_warn("can't find zfs_dbgmsgs");
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   883
		return (DCMD_ERR);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   884
	}
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   885
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   886
	if (mdb_pwalk("list", dbgmsg_cb, &verbose, sym.st_value) != 0) {
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   887
		mdb_warn("can't walk zfs_dbgmsgs");
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   888
		return (DCMD_ERR);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   889
	}
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   890
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   891
	return (DCMD_OK);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   892
}
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
   893
3403
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   894
/*ARGSUSED*/
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   895
static int
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   896
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
   897
{
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   898
	kstat_named_t *stats;
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   899
	GElf_Sym sym;
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   900
	int nstats, i;
3403
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   901
	uint_t opt_a = FALSE;
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   902
	uint_t opt_b = FALSE;
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   903
	uint_t shift = 0;
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   904
	const char *suffix;
3403
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   905
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   906
	static const char *bytestats[] = {
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   907
		"p", "c", "c_min", "c_max", "size", NULL
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   908
	};
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   909
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   910
	static const char *extras[] = {
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   911
		"arc_no_grow", "arc_tempreserve",
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   912
		"arc_meta_used", "arc_meta_limit", "arc_meta_max",
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   913
		NULL
3403
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
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   916
	if (mdb_lookup_by_name("arc_stats", &sym) == -1) {
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   917
		mdb_warn("failed to find 'arc_stats'");
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   918
		return (DCMD_ERR);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   919
	}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   920
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   921
	stats = mdb_zalloc(sym.st_size, UM_SLEEP | UM_GC);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   922
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   923
	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
   924
		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
   925
		return (DCMD_ERR);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   926
	}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   927
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   928
	nstats = sym.st_size / sizeof (kstat_named_t);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   929
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   930
	/* NB: -a / opt_a are ignored for backwards compatability */
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   931
	if (mdb_getopts(argc, argv,
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   932
	    'a', MDB_OPT_SETBITS, TRUE, &opt_a,
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   933
	    'b', MDB_OPT_SETBITS, TRUE, &opt_b,
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   934
	    'k', MDB_OPT_SETBITS, 10, &shift,
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   935
	    'm', MDB_OPT_SETBITS, 20, &shift,
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   936
	    'g', MDB_OPT_SETBITS, 30, &shift,
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   937
	    NULL) != argc)
3403
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   938
		return (DCMD_USAGE);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   939
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   940
	if (!opt_b && !shift)
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   941
		shift = 20;
3403
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   942
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   943
	switch (shift) {
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   944
	case 0:
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   945
		suffix = "B";
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   946
		break;
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   947
	case 10:
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   948
		suffix = "KB";
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   949
		break;
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   950
	case 20:
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   951
		suffix = "MB";
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   952
		break;
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   953
	case 30:
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   954
		suffix = "GB";
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   955
		break;
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   956
	default:
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   957
		suffix = "XX";
3403
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   958
	}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   959
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   960
	for (i = 0; i < nstats; i++) {
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   961
		int j;
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   962
		boolean_t bytes = B_FALSE;
3403
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   963
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   964
		for (j = 0; bytestats[j]; j++) {
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   965
			if (strcmp(stats[i].name, bytestats[j]) == 0) {
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   966
				bytes = B_TRUE;
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   967
				break;
3403
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   968
			}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   969
		}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   970
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   971
		if (bytes) {
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   972
			mdb_printf("%-25s = %9llu %s\n", stats[i].name,
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   973
			    stats[i].value.ui64 >> shift, suffix);
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   974
		} else {
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   975
			mdb_printf("%-25s = %9llu\n", stats[i].name,
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   976
			    stats[i].value.ui64);
3403
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   977
		}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   978
	}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   979
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   980
	for (i = 0; extras[i]; i++) {
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   981
		uint64_t buf;
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   982
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   983
		if (mdb_lookup_by_name(extras[i], &sym) == -1) {
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   984
			mdb_warn("failed to find '%s'", extras[i]);
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   985
			return (DCMD_ERR);
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   986
		}
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   987
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   988
		if (sym.st_size != sizeof (uint64_t) &&
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   989
		    sym.st_size != sizeof (uint32_t)) {
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   990
			mdb_warn("expected scalar for variable '%s'\n",
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   991
			    extras[i]);
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   992
			return (DCMD_ERR);
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   993
		}
3403
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
   994
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   995
		if (mdb_vread(&buf, sym.st_size, sym.st_value) == -1) {
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   996
			mdb_warn("couldn't read '%s'", extras[i]);
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   997
			return (DCMD_ERR);
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   998
		}
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
   999
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
  1000
		mdb_printf("%-25s = ", extras[i]);
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
  1001
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
  1002
		/* NB: all the 64-bit extras happen to be byte counts */
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
  1003
		if (sym.st_size == sizeof (uint64_t))
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
  1004
			mdb_printf("%9llu %s\n", buf >> shift, suffix);
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
  1005
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
  1006
		if (sym.st_size == sizeof (uint32_t))
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
  1007
			mdb_printf("%9d\n", *((uint32_t *)&buf));
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
  1008
	}
3403
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
  1009
	return (DCMD_OK);
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
  1010
}
e52013d23622 6510807 ARC statistics should be exported via kstat
bmc
parents: 3361
diff changeset
  1011
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1012
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1013
 * ::spa
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1014
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1015
 * 	-c	Print configuration information as well
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1016
 * 	-v	Print vdev state
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1017
 * 	-e	Print vdev error stats
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1018
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1019
 * Print a summarized spa_t.  When given no arguments, prints out a table of all
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1020
 * active pools on the system.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1021
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1022
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1023
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1024
spa_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1025
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1026
	spa_t spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1027
	const char *statetab[] = { "ACTIVE", "EXPORTED", "DESTROYED",
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7390
diff changeset
  1028
		"SPARE", "L2CACHE", "UNINIT", "UNAVAIL", "POTENTIAL" };
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1029
	const char *state;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1030
	int config = FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1031
	int vdevs = FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1032
	int errors = FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1033
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1034
	if (mdb_getopts(argc, argv,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1035
	    'c', MDB_OPT_SETBITS, TRUE, &config,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1036
	    'v', MDB_OPT_SETBITS, TRUE, &vdevs,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1037
	    'e', MDB_OPT_SETBITS, TRUE, &errors,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1038
	    NULL) != argc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1039
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1040
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1041
	if (!(flags & DCMD_ADDRSPEC)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1042
		if (mdb_walk_dcmd("spa", "spa", argc, argv) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1043
			mdb_warn("can't walk spa");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1044
			return (DCMD_ERR);
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
		return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1048
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1049
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1050
	if (flags & DCMD_PIPE_OUT) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1051
		mdb_printf("%#lr\n", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1052
		return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1053
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1054
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1055
	if (DCMD_HDRSPEC(flags))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1056
		mdb_printf("%<u>%-?s %9s %-*s%</u>\n", "ADDR", "STATE",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1057
		    sizeof (uintptr_t) == 4 ? 60 : 52, "NAME");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1058
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1059
	if (mdb_vread(&spa, sizeof (spa), addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1060
		mdb_warn("failed to read spa_t at %p", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1061
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1062
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1063
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1064
	if (spa.spa_state < 0 || spa.spa_state > POOL_STATE_UNAVAIL)
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 952
diff changeset
  1065
		state = "UNKNOWN";
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1066
	else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1067
		state = statetab[spa.spa_state];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1068
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7390
diff changeset
  1069
	mdb_printf("%0?p %9s %s\n", addr, state, spa.spa_name);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1070
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1071
	if (config) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1072
		mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1073
		mdb_inc_indent(4);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1074
		if (mdb_call_dcmd("spa_config", addr, flags, 0,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1075
		    NULL) != DCMD_OK)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1076
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1077
		mdb_dec_indent(4);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1078
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1079
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1080
	if (vdevs || errors) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1081
		mdb_arg_t v;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1082
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1083
		v.a_type = MDB_TYPE_STRING;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1084
		v.a_un.a_str = "-e";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1085
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1086
		mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1087
		mdb_inc_indent(4);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1088
		if (mdb_call_dcmd("spa_vdevs", addr, flags, errors ? 1 : 0,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1089
		    &v) != DCMD_OK)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1090
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1091
		mdb_dec_indent(4);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1092
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1093
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1094
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1095
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1096
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1097
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1098
 * ::spa_config
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1099
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1100
 * Given a spa_t, print the configuration information stored in spa_config.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1101
 * 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
  1102
 * We simply read the value of spa_config and pass off to ::nvlist.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1103
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1104
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1105
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1106
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
  1107
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1108
	spa_t spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1109
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1110
	if (argc != 0 || !(flags & DCMD_ADDRSPEC))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1111
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1112
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1113
	if (mdb_vread(&spa, sizeof (spa), addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1114
		mdb_warn("failed to read spa_t at %p", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1115
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1116
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1117
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1118
	if (spa.spa_config == NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1119
		mdb_printf("(none)\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1120
		return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1121
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1122
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1123
	return (mdb_call_dcmd("nvlist", (uintptr_t)spa.spa_config, flags,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1124
	    0, NULL));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1125
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1126
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1127
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1128
 * ::vdev
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1129
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1130
 * Print out a summarized vdev_t, in the following form:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1131
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1132
 * ADDR             STATE	AUX            DESC
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1133
 * fffffffbcde23df0 HEALTHY	-              /dev/dsk/c0t0d0
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1134
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1135
 * If '-r' is specified, recursively visit all children.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1136
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1137
 * With '-e', the statistics associated with the vdev are printed as well.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1138
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1139
static int
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
  1140
do_print_vdev(uintptr_t addr, int flags, int depth, int stats,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1141
    int recursive)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1142
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1143
	vdev_t vdev;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1144
	char desc[MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1145
	int c, children;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1146
	uintptr_t *child;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1147
	const char *state, *aux;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1148
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1149
	if (mdb_vread(&vdev, sizeof (vdev), (uintptr_t)addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1150
		mdb_warn("failed to read vdev_t at %p\n", (uintptr_t)addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1151
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1152
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1153
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1154
	if (flags & DCMD_PIPE_OUT) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1155
		mdb_printf("%#lr", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1156
	} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1157
		if (vdev.vdev_path != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1158
			if (mdb_readstr(desc, sizeof (desc),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1159
			    (uintptr_t)vdev.vdev_path) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1160
				mdb_warn("failed to read vdev_path at %p\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1161
				    vdev.vdev_path);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1162
				return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1163
			}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1164
		} else if (vdev.vdev_ops != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1165
			vdev_ops_t ops;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1166
			if (mdb_vread(&ops, sizeof (ops),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1167
			    (uintptr_t)vdev.vdev_ops) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1168
				mdb_warn("failed to read vdev_ops at %p\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1169
				    vdev.vdev_ops);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1170
				return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1171
			}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1172
			(void) strcpy(desc, ops.vdev_op_type);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1173
		} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1174
			(void) strcpy(desc, "<unknown>");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1175
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1176
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1177
		if (depth == 0 && DCMD_HDRSPEC(flags))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1178
			mdb_printf("%<u>%-?s %-9s %-12s %-*s%</u>\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1179
			    "ADDR", "STATE", "AUX",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1180
			    sizeof (uintptr_t) == 4 ? 43 : 35,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1181
			    "DESCRIPTION");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1182
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1183
		mdb_printf("%0?p ", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1184
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1185
		switch (vdev.vdev_state) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1186
		case VDEV_STATE_CLOSED:
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1187
			state = "CLOSED";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1188
			break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1189
		case VDEV_STATE_OFFLINE:
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1190
			state = "OFFLINE";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1191
			break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1192
		case VDEV_STATE_CANT_OPEN:
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1193
			state = "CANT_OPEN";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1194
			break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1195
		case VDEV_STATE_DEGRADED:
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1196
			state = "DEGRADED";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1197
			break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1198
		case VDEV_STATE_HEALTHY:
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1199
			state = "HEALTHY";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1200
			break;
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4217
diff changeset
  1201
		case VDEV_STATE_REMOVED:
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4217
diff changeset
  1202
			state = "REMOVED";
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4217
diff changeset
  1203
			break;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4217
diff changeset
  1204
		case VDEV_STATE_FAULTED:
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4217
diff changeset
  1205
			state = "FAULTED";
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4217
diff changeset
  1206
			break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1207
		default:
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1208
			state = "UNKNOWN";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1209
			break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1210
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1211
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1212
		switch (vdev.vdev_stat.vs_aux) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1213
		case VDEV_AUX_NONE:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1214
			aux = "-";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1215
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1216
		case VDEV_AUX_OPEN_FAILED:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1217
			aux = "OPEN_FAILED";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1218
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1219
		case VDEV_AUX_CORRUPT_DATA:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1220
			aux = "CORRUPT_DATA";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1221
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1222
		case VDEV_AUX_NO_REPLICAS:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1223
			aux = "NO_REPLICAS";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1224
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1225
		case VDEV_AUX_BAD_GUID_SUM:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1226
			aux = "BAD_GUID_SUM";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1227
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1228
		case VDEV_AUX_TOO_SMALL:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1229
			aux = "TOO_SMALL";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1230
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1231
		case VDEV_AUX_BAD_LABEL:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1232
			aux = "BAD_LABEL";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1233
			break;
7294
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1234
		case VDEV_AUX_VERSION_NEWER:
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1235
			aux = "VERS_NEWER";
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1236
			break;
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1237
		case VDEV_AUX_VERSION_OLDER:
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1238
			aux = "VERS_OLDER";
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1239
			break;
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1240
		case VDEV_AUX_SPARED:
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1241
			aux = "SPARED";
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1242
			break;
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1243
		case VDEV_AUX_ERR_EXCEEDED:
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1244
			aux = "ERR_EXCEEDED";
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1245
			break;
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1246
		case VDEV_AUX_IO_FAILURE:
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1247
			aux = "IO_FAILURE";
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1248
			break;
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1249
		case VDEV_AUX_BAD_LOG:
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1250
			aux = "BAD_LOG";
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 6643
diff changeset
  1251
			break;
11422
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11147
diff changeset
  1252
		case VDEV_AUX_EXTERNAL:
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11147
diff changeset
  1253
			aux = "EXTERNAL";
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11147
diff changeset
  1254
			break;
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11147
diff changeset
  1255
		case VDEV_AUX_SPLIT_POOL:
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11147
diff changeset
  1256
			aux = "SPLIT_POOL";
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11147
diff changeset
  1257
			break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1258
		default:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1259
			aux = "UNKNOWN";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1260
			break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1261
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1262
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1263
		mdb_printf("%-9s %-12s %*s%s\n", state, aux, depth, "", desc);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1264
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1265
		if (stats) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1266
			vdev_stat_t *vs = &vdev.vdev_stat;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1267
			int i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1268
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1269
			mdb_inc_indent(4);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1270
			mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1271
			mdb_printf("%<u>       %12s %12s %12s %12s "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1272
			    "%12s%</u>\n", "READ", "WRITE", "FREE", "CLAIM",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1273
			    "IOCTL");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1274
			mdb_printf("OPS     ");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1275
			for (i = 1; i < ZIO_TYPES; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1276
				mdb_printf("%11#llx%s", vs->vs_ops[i],
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1277
				    i == ZIO_TYPES - 1 ? "" : "  ");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1278
			mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1279
			mdb_printf("BYTES   ");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1280
			for (i = 1; i < ZIO_TYPES; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1281
				mdb_printf("%11#llx%s", vs->vs_bytes[i],
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1282
				    i == ZIO_TYPES - 1 ? "" : "  ");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1283
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1284
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1285
			mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1286
			mdb_printf("EREAD    %10#llx\n", vs->vs_read_errors);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1287
			mdb_printf("EWRITE   %10#llx\n", vs->vs_write_errors);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1288
			mdb_printf("ECKSUM   %10#llx\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1289
			    vs->vs_checksum_errors);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1290
			mdb_dec_indent(4);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1291
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1292
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
  1293
		if (stats)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1294
			mdb_printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1295
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1296
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1297
	children = vdev.vdev_children;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1298
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1299
	if (children == 0 || !recursive)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1300
		return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1301
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1302
	child = mdb_alloc(children * sizeof (void *), UM_SLEEP | UM_GC);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1303
	if (mdb_vread(child, children * sizeof (void *),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1304
	    (uintptr_t)vdev.vdev_child) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1305
		mdb_warn("failed to read vdev children at %p", vdev.vdev_child);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1306
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1307
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1308
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1309
	for (c = 0; c < children; c++) {
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
  1310
		if (do_print_vdev(child[c], flags, depth + 2, stats,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1311
		    recursive))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1312
			return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1313
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1314
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1315
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1316
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1317
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1318
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1319
vdev_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1320
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1321
	int recursive = FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1322
	int stats = FALSE;
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1323
	uint64_t depth = 0;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1324
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1325
	if (mdb_getopts(argc, argv,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1326
	    'r', MDB_OPT_SETBITS, TRUE, &recursive,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1327
	    'e', MDB_OPT_SETBITS, TRUE, &stats,
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1328
	    'd', MDB_OPT_UINT64, &depth,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1329
	    NULL) != argc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1330
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1331
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1332
	if (!(flags & DCMD_ADDRSPEC)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1333
		mdb_warn("no vdev_t address given\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1334
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1335
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1336
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1337
	return (do_print_vdev(addr, flags, (int)depth, stats, recursive));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1338
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1339
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1340
typedef struct metaslab_walk_data {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1341
	uint64_t mw_numvdevs;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1342
	uintptr_t *mw_vdevs;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1343
	int mw_curvdev;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1344
	uint64_t mw_nummss;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1345
	uintptr_t *mw_mss;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1346
	int mw_curms;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1347
} metaslab_walk_data_t;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1348
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1349
static int
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1350
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
  1351
{
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1352
	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
  1353
	metaslab_t ms;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1354
	uintptr_t msp;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1355
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1356
	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
  1357
		return (WALK_DONE);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1358
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1359
	if (mw->mw_mss == NULL) {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1360
		uintptr_t mssp;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1361
		uintptr_t vdevp;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1362
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1363
		ASSERT(mw->mw_curms == 0);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1364
		ASSERT(mw->mw_nummss == 0);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1365
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1366
		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
  1367
		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
  1368
		    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
  1369
			return (WALK_ERR);
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
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1372
		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
  1373
		    UM_SLEEP | UM_GC);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1374
		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
  1375
		    mssp) == -1) {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1376
			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
  1377
			return (WALK_ERR);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1378
		}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1379
	}
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
	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
  1382
		mw->mw_mss = NULL;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1383
		mw->mw_curms = 0;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1384
		mw->mw_nummss = 0;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1385
		mw->mw_curvdev++;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1386
		return (WALK_NEXT);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1387
	}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1388
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1389
	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
  1390
	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
  1391
		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
  1392
		return (WALK_ERR);
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
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1395
	mw->mw_curms++;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1396
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1397
	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
  1398
}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1399
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1400
/* ARGSUSED */
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1401
static int
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1402
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
  1403
{
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1404
	metaslab_walk_data_t *mw;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1405
	uintptr_t root_vdevp;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1406
	uintptr_t childp;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1407
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1408
	if (wsp->walk_addr == NULL) {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1409
		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
  1410
		return (WALK_ERR);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1411
	}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1412
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1413
	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
  1414
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1415
	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
  1416
	    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
  1417
	    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
  1418
		return (DCMD_ERR);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1419
	}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1420
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1421
	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
  1422
	    UM_SLEEP | UM_GC);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1423
	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
  1424
	    childp) == -1) {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1425
		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
  1426
		return (DCMD_ERR);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1427
	}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1428
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1429
	wsp->walk_data = mw;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1430
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1431
	return (WALK_NEXT);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1432
}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1433
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1434
typedef struct mdb_spa {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1435
	uintptr_t spa_dsl_pool;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1436
	uintptr_t spa_root_vdev;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1437
} mdb_spa_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1438
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1439
typedef struct mdb_dsl_dir {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1440
	uintptr_t dd_phys;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1441
	int64_t dd_space_towrite[TXG_SIZE];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1442
} mdb_dsl_dir_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1443
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1444
typedef struct mdb_dsl_dir_phys {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1445
	uint64_t dd_used_bytes;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1446
	uint64_t dd_compressed_bytes;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1447
	uint64_t dd_uncompressed_bytes;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1448
} mdb_dsl_dir_phys_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1449
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1450
typedef struct mdb_vdev {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1451
	uintptr_t vdev_parent;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1452
	uintptr_t vdev_ms;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1453
	uint64_t vdev_ms_count;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1454
	vdev_stat_t vdev_stat;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1455
} mdb_vdev_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1456
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1457
typedef struct mdb_metaslab {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1458
	space_map_t ms_allocmap[TXG_SIZE];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1459
	space_map_t ms_freemap[TXG_SIZE];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1460
	space_map_t ms_map;
1732
9e3ae798af31 6280668 pluggable block allocation policy
bonwick
parents: 1544
diff changeset
  1461
	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
  1462
	space_map_obj_t ms_smo_syncing;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1463
} mdb_metaslab_t;
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
typedef struct space_data {
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1466
	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
  1467
	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
  1468
	uint64_t ms_map;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1469
	uint64_t avail;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1470
	uint64_t nowavail;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1471
} space_data_t;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1472
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1473
/* ARGSUSED */
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1474
static int
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1475
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
  1476
{
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1477
	space_data_t *sd = arg;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1478
	mdb_metaslab_t ms;
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1479
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1480
	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
  1481
	    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
  1482
	    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
  1483
	    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
  1484
	    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
  1485
		return (WALK_ERR);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1486
	}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1487
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1488
	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
  1489
	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
  1490
	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
  1491
	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
  1492
	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
  1493
	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
  1494
	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
  1495
	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
  1496
	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
  1497
	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
  1498
	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
  1499
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1500
	return (WALK_NEXT);
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1501
}
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1502
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1503
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1504
 * ::spa_space [-b]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1505
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1506
 * Given a spa_t, print out it's on-disk space usage and in-core
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1507
 * estimates of future usage.  If -b is given, print space in bytes.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1508
 * Otherwise print in megabytes.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1509
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1510
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1511
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1512
spa_space(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1513
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1514
	mdb_spa_t spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1515
	uintptr_t dp_root_dir;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1516
	mdb_dsl_dir_t dd;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1517
	mdb_dsl_dir_phys_t dsp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1518
	uint64_t children;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1519
	uintptr_t childaddr;
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1520
	space_data_t sd;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1521
	int shift = 20;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1522
	char *suffix = "M";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1523
	int bits = FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1524
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1525
	if (mdb_getopts(argc, argv, 'b', MDB_OPT_SETBITS, TRUE, &bits, NULL) !=
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1526
	    argc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1527
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1528
	if (!(flags & DCMD_ADDRSPEC))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1529
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1530
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1531
	if (bits) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1532
		shift = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1533
		suffix = "";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1534
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1535
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1536
	if (GETMEMB(addr, struct spa, spa_dsl_pool, spa.spa_dsl_pool) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1537
	    GETMEMB(addr, struct spa, spa_root_vdev, spa.spa_root_vdev) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1538
	    GETMEMB(spa.spa_root_vdev, struct vdev, vdev_children, children) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1539
	    GETMEMB(spa.spa_root_vdev, struct vdev, vdev_child, childaddr) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1540
	    GETMEMB(spa.spa_dsl_pool, struct dsl_pool,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1541
	    dp_root_dir, dp_root_dir) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1542
	    GETMEMB(dp_root_dir, struct dsl_dir, dd_phys, dd.dd_phys) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1543
	    GETMEMB(dp_root_dir, struct dsl_dir,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1544
	    dd_space_towrite, dd.dd_space_towrite) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1545
	    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
  1546
	    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
  1547
	    GETMEMB(dd.dd_phys, struct dsl_dir_phys,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1548
	    dd_compressed_bytes, dsp.dd_compressed_bytes) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1549
	    GETMEMB(dd.dd_phys, struct dsl_dir_phys,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1550
	    dd_uncompressed_bytes, dsp.dd_uncompressed_bytes)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1551
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1552
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1553
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1554
	mdb_printf("dd_space_towrite = %llu%s %llu%s %llu%s %llu%s\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1555
	    dd.dd_space_towrite[0] >> shift, suffix,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1556
	    dd.dd_space_towrite[1] >> shift, suffix,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1557
	    dd.dd_space_towrite[2] >> shift, suffix,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1558
	    dd.dd_space_towrite[3] >> shift, suffix);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1559
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1560
	mdb_printf("dd_phys.dd_used_bytes = %llu%s\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1561
	    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
  1562
	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
  1563
	    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
  1564
	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
  1565
	    dsp.dd_uncompressed_bytes >> shift, suffix);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1566
2459
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1567
	bzero(&sd, sizeof (sd));
7511d9859fcd 6452923 really out of space panic even though ms_map.sm_space > 0
ahrens
parents: 2082
diff changeset
  1568
	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
  1569
		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
  1570
		return (DCMD_ERR);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1571
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1572
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1573
	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
  1574
	    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
  1575
	    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
  1576
	    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
  1577
	    sd.ms_allocmap[3] >> shift, suffix);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1578
	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
  1579
	    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
  1580
	    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
  1581
	    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
  1582
	    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
  1583
	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
  1584
	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
  1585
	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
  1586
	    sd.nowavail >> shift, suffix);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1587
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1588
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1589
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1590
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1591
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1592
 * ::spa_verify
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1593
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1594
 * Given a spa_t, verify that that the pool is self-consistent.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1595
 * Currently, it only checks to make sure that the vdev tree exists.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1596
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1597
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1598
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1599
spa_verify(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1600
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1601
	spa_t spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1602
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1603
	if (argc != 0 || !(flags & DCMD_ADDRSPEC))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1604
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1605
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1606
	if (mdb_vread(&spa, sizeof (spa), addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1607
		mdb_warn("failed to read spa_t at %p", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1608
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1609
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1610
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1611
	if (spa.spa_root_vdev == NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1612
		mdb_printf("no vdev tree present\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1613
		return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1614
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1615
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1616
	return (DCMD_OK);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1617
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1618
8341
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1619
static int
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1620
spa_print_aux(spa_aux_vdev_t *sav, uint_t flags, mdb_arg_t *v,
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1621
    const char *name)
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1622
{
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1623
	uintptr_t *aux;
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1624
	size_t len;
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1625
	int ret, i;
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1626
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1627
	/*
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1628
	 * Iterate over aux vdevs and print those out as well.  This is a
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1629
	 * little annoying because we don't have a root vdev to pass to ::vdev.
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1630
	 * Instead, we print a single line and then call it for each child
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1631
	 * vdev.
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1632
	 */
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1633
	if (sav->sav_count != 0) {
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1634
		v[1].a_type = MDB_TYPE_STRING;
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1635
		v[1].a_un.a_str = "-d";
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1636
		v[2].a_type = MDB_TYPE_IMMEDIATE;
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1637
		v[2].a_un.a_val = 2;
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1638
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1639
		len = sav->sav_count * sizeof (uintptr_t);
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1640
		aux = mdb_alloc(len, UM_SLEEP);
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1641
		if (mdb_vread(aux, len,
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1642
		    (uintptr_t)sav->sav_vdevs) == -1) {
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1643
			mdb_free(aux, len);
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1644
			mdb_warn("failed to read l2cache vdevs at %p",
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1645
			    sav->sav_vdevs);
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1646
			return (DCMD_ERR);
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1647
		}
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1648
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1649
		mdb_printf("%-?s %-9s %-12s %s\n", "-", "-", "-", name);
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1650
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1651
		for (i = 0; i < sav->sav_count; i++) {
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1652
			ret = mdb_call_dcmd("vdev", aux[i], flags, 3, v);
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1653
			if (ret != DCMD_OK) {
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1654
				mdb_free(aux, len);
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1655
				return (ret);
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1656
			}
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1657
		}
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1658
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1659
		mdb_free(aux, len);
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1660
	}
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1661
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1662
	return (0);
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1663
}
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1664
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1665
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1666
 * ::spa_vdevs
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1667
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1668
 * 	-e	Include error stats
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1669
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1670
 * Print out a summarized list of vdevs for the given spa_t.
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1671
 * This is accomplished by invoking "::vdev -re" on the root vdev, as well as
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1672
 * iterating over the cache devices.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1673
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1674
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1675
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1676
spa_vdevs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1677
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1678
	spa_t spa;
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1679
	mdb_arg_t v[3];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1680
	int errors = FALSE;
8341
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1681
	int ret;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1682
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1683
	if (mdb_getopts(argc, argv,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1684
	    'e', MDB_OPT_SETBITS, TRUE, &errors,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1685
	    NULL) != argc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1686
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1687
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1688
	if (!(flags & DCMD_ADDRSPEC))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1689
		return (DCMD_USAGE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1690
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1691
	if (mdb_vread(&spa, sizeof (spa), addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1692
		mdb_warn("failed to read spa_t at %p", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1693
		return (DCMD_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1694
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1695
952
12ec54aa046e 6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents: 789
diff changeset
  1696
	/*
12ec54aa046e 6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents: 789
diff changeset
  1697
	 * 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
  1698
	 */
12ec54aa046e 6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents: 789
diff changeset
  1699
	if (spa.spa_root_vdev == NULL) {
12ec54aa046e 6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents: 789
diff changeset
  1700
		mdb_printf("no associated vdevs\n");
12ec54aa046e 6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents: 789
diff changeset
  1701
		return (DCMD_OK);
12ec54aa046e 6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents: 789
diff changeset
  1702
	}
12ec54aa046e 6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents: 789
diff changeset
  1703
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1704
	v[0].a_type = MDB_TYPE_STRING;
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1705
	v[0].a_un.a_str = errors ? "-re" : "-r";
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1706
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1707
	ret = mdb_call_dcmd("vdev", (uintptr_t)spa.spa_root_vdev,
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1708
	    flags, 1, v);
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1709
	if (ret != DCMD_OK)
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1710
		return (ret);
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1711
8341
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1712
	if (spa_print_aux(&spa.spa_l2cache, flags, v, "cache") != 0 ||
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1713
	    spa_print_aux(&spa.spa_spares, flags, v, "spares") != 0)
53c5e7987263 6783576 ::spa -v should include spares
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7846
diff changeset
  1714
		return (DCMD_ERR);
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1715
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6245
diff changeset
  1716
	return (DCMD_OK);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1717
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1718
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1719
/*
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1720
 * ::zio
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1721
 *
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1722
 * 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
  1723
 * 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
  1724
 * 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
  1725
 * '::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
  1726
 *
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1727
 *	ADDRESS		TYPE	STAGE		WAITER
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1728
 *
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1729
 * 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
  1730
 * descend down the tree.
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1731
 */
4217
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1732
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1733
#define	ZIO_MAXINDENT	24
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1734
#define	ZIO_MAXWIDTH	(sizeof (uintptr_t) * 2 + ZIO_MAXINDENT)
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1735
#define	ZIO_WALK_SELF	0
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1736
#define	ZIO_WALK_CHILD	1
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1737
#define	ZIO_WALK_PARENT	2
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1738
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1739
typedef struct zio_print_args {
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1740
	int	zpa_current_depth;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1741
	int	zpa_min_depth;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1742
	int	zpa_max_depth;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1743
	int	zpa_type;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1744
	uint_t	zpa_flags;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1745
} zio_print_args_t;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1746
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1747
static int zio_child_cb(uintptr_t addr, const void *unknown, void *arg);
4217
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1748
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1749
static int
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1750
zio_print_cb(uintptr_t addr, const void *data, void *priv)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1751
{
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1752
	const zio_t *zio = data;
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1753
	zio_print_args_t *zpa = priv;
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1754
	mdb_ctf_id_t type_enum, stage_enum;
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1755
	int indent = zpa->zpa_current_depth;
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1756
	const char *type, *stage;
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1757
	uintptr_t laddr;
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1758
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1759
	if (indent > ZIO_MAXINDENT)
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1760
		indent = ZIO_MAXINDENT;
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1761
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1762
	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
  1763
	    mdb_ctf_lookup_by_name("enum zio_stage", &stage_enum) == -1) {
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1764
		mdb_warn("failed to lookup zio enums");
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1765
		return (WALK_ERR);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1766
	}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1767
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1768
	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
  1769
		type += sizeof ("ZIO_TYPE_") - 1;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1770
	else
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1771
		type = "?";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1772
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1773
	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
  1774
		stage += sizeof ("ZIO_STAGE_") - 1;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1775
	else
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1776
		stage = "?";
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1777
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1778
	if (zpa->zpa_current_depth >= zpa->zpa_min_depth) {
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1779
		if (zpa->zpa_flags & DCMD_PIPE_OUT) {
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1780
			mdb_printf("%?p\n", addr);
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1781
		} else {
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1782
			mdb_printf("%*s%-*p %-5s %-16s ", indent, "",
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1783
			    ZIO_MAXWIDTH - indent, addr, type, stage);
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1784
			if (zio->io_waiter)
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1785
				mdb_printf("%?p\n", zio->io_waiter);
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1786
			else
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1787
				mdb_printf("-\n");
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1788
		}
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1789
	}
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1790
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1791
	if (zpa->zpa_current_depth >= zpa->zpa_max_depth)
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1792
		return (WALK_NEXT);
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1793
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1794
	if (zpa->zpa_type == ZIO_WALK_PARENT)
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1795
		laddr = addr + OFFSETOF(zio_t, io_parent_list);
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1796
	else
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1797
		laddr = addr + OFFSETOF(zio_t, io_child_list);
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1798
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1799
	zpa->zpa_current_depth++;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1800
	if (mdb_pwalk("list", zio_child_cb, zpa, laddr) != 0) {
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1801
		mdb_warn("failed to walk zio_t children at %p\n", laddr);
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1802
		return (WALK_ERR);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1803
	}
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1804
	zpa->zpa_current_depth--;
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1805
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1806
	return (WALK_NEXT);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1807
}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1808
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1809
/* ARGSUSED */
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1810
static int
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1811
zio_child_cb(uintptr_t addr, const void *unknown, void *arg)
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1812
{
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1813
	zio_link_t zl;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1814
	zio_t zio;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1815
	uintptr_t ziop;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1816
	zio_print_args_t *zpa = arg;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1817
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1818
	if (mdb_vread(&zl, sizeof (zl), addr) == -1) {
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1819
		mdb_warn("failed to read zio_link_t at %p", addr);
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1820
		return (WALK_ERR);
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1821
	}
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1822
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1823
	if (zpa->zpa_type == ZIO_WALK_PARENT)
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1824
		ziop = (uintptr_t)zl.zl_parent;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1825
	else
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1826
		ziop = (uintptr_t)zl.zl_child;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1827
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1828
	if (mdb_vread(&zio, sizeof (zio_t), ziop) == -1) {
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1829
		mdb_warn("failed to read zio_t at %p", ziop);
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1830
		return (WALK_ERR);
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1831
	}
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1832
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1833
	return (zio_print_cb(ziop, &zio, arg));
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1834
}
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1835
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1836
/* ARGSUSED */
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1837
static int
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1838
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
  1839
{
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1840
	zio_t zio;
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1841
	zio_print_args_t zpa = { 0 };
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1842
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1843
	if (!(flags & DCMD_ADDRSPEC))
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1844
		return (DCMD_USAGE);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1845
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1846
	if (mdb_getopts(argc, argv,
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1847
	    'r', MDB_OPT_SETBITS, INT_MAX, &zpa.zpa_max_depth,
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1848
	    'c', MDB_OPT_SETBITS, ZIO_WALK_CHILD, &zpa.zpa_type,
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1849
	    'p', MDB_OPT_SETBITS, ZIO_WALK_PARENT, &zpa.zpa_type,
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1850
	    NULL) != argc)
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1851
		return (DCMD_USAGE);
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1852
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1853
	zpa.zpa_flags = flags;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1854
	if (zpa.zpa_max_depth != 0) {
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1855
		if (zpa.zpa_type == ZIO_WALK_SELF)
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1856
			zpa.zpa_type = ZIO_WALK_CHILD;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1857
	} else if (zpa.zpa_type != ZIO_WALK_SELF) {
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1858
		zpa.zpa_min_depth = 1;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1859
		zpa.zpa_max_depth = 1;
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1860
	}
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1861
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1862
	if (mdb_vread(&zio, sizeof (zio_t), 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", addr);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1864
		return (DCMD_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
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1867
	if (!(flags & DCMD_PIPE_OUT) && DCMD_HDRSPEC(flags))
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1868
		mdb_printf("%<u>%-*s %-5s %-16s %-?s%</u>\n", ZIO_MAXWIDTH,
4217
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1869
		    "ADDRESS", "TYPE", "STAGE", "WAITER");
3411a82f178f 6552521 truss dumps core with multibyte characters in syscall args
eschrock
parents: 4055
diff changeset
  1870
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  1871
	if (zio_print_cb(addr, &zio, &zpa) != WALK_NEXT)
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1872
		return (DCMD_ERR);
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
	return (DCMD_OK);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1875
}
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
/*
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1878
 * [addr]::zio_state
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
 * 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
  1881
 * pool.  This is equivalent to '::walk zio_root | ::zio'.
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1882
 */
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1883
/*ARGSUSED*/
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1884
static int
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1885
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
  1886
{
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1887
	/*
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1888
	 * 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
  1889
	 * 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
  1890
	 * non-existent spa_t.
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
	if (!(flags & DCMD_ADDRSPEC))
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1893
		addr = 0;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1894
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1895
	return (mdb_pwalk_dcmd("zio_root", "zio", argc, argv, addr));
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1896
}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  1897
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1898
typedef struct txg_list_walk_data {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1899
	uintptr_t lw_head[TXG_SIZE];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1900
	int	lw_txgoff;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1901
	int	lw_maxoff;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1902
	size_t	lw_offset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1903
	void	*lw_obj;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1904
} txg_list_walk_data_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1905
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1906
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1907
txg_list_walk_init_common(mdb_walk_state_t *wsp, int txg, int maxoff)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1908
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1909
	txg_list_walk_data_t *lwd;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1910
	txg_list_t list;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1911
	int i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1912
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1913
	lwd = mdb_alloc(sizeof (txg_list_walk_data_t), UM_SLEEP | UM_GC);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1914
	if (mdb_vread(&list, sizeof (txg_list_t), wsp->walk_addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1915
		mdb_warn("failed to read txg_list_t at %#lx", wsp->walk_addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1916
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1917
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1918
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1919
	for (i = 0; i < TXG_SIZE; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1920
		lwd->lw_head[i] = (uintptr_t)list.tl_head[i];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1921
	lwd->lw_offset = list.tl_offset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1922
	lwd->lw_obj = mdb_alloc(lwd->lw_offset + sizeof (txg_node_t),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1923
	    UM_SLEEP | UM_GC);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1924
	lwd->lw_txgoff = txg;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1925
	lwd->lw_maxoff = maxoff;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1926
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1927
	wsp->walk_addr = lwd->lw_head[lwd->lw_txgoff];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1928
	wsp->walk_data = lwd;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1929
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1930
	return (WALK_NEXT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1931
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1932
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1933
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1934
txg_list_walk_init(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1935
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1936
	return (txg_list_walk_init_common(wsp, 0, TXG_SIZE-1));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1937
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1938
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1939
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1940
txg_list0_walk_init(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1941
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1942
	return (txg_list_walk_init_common(wsp, 0, 0));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1943
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1944
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1945
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1946
txg_list1_walk_init(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1947
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1948
	return (txg_list_walk_init_common(wsp, 1, 1));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1949
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1950
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1951
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1952
txg_list2_walk_init(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1953
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1954
	return (txg_list_walk_init_common(wsp, 2, 2));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1955
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1956
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1957
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1958
txg_list3_walk_init(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1959
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1960
	return (txg_list_walk_init_common(wsp, 3, 3));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1961
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1962
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1963
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1964
txg_list_walk_step(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1965
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1966
	txg_list_walk_data_t *lwd = wsp->walk_data;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1967
	uintptr_t addr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1968
	txg_node_t *node;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1969
	int status;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1970
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1971
	while (wsp->walk_addr == NULL && lwd->lw_txgoff < lwd->lw_maxoff) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1972
		lwd->lw_txgoff++;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1973
		wsp->walk_addr = lwd->lw_head[lwd->lw_txgoff];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1974
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1975
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1976
	if (wsp->walk_addr == NULL)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1977
		return (WALK_DONE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1978
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1979
	addr = wsp->walk_addr - lwd->lw_offset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1980
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1981
	if (mdb_vread(lwd->lw_obj,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1982
	    lwd->lw_offset + sizeof (txg_node_t), addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1983
		mdb_warn("failed to read list element at %#lx", addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1984
		return (WALK_ERR);
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
	status = wsp->walk_callback(addr, lwd->lw_obj, wsp->walk_cbdata);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1988
	node = (txg_node_t *)((uintptr_t)lwd->lw_obj + lwd->lw_offset);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1989
	wsp->walk_addr = (uintptr_t)node->tn_next[lwd->lw_txgoff];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1990
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1991
	return (status);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1992
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1993
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1994
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1995
 * ::walk spa
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1996
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1997
 * Walk all named spa_t structures in the namespace.  This is nothing more than
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1998
 * a layered avl walk.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1999
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2000
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2001
spa_walk_init(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2002
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2003
	GElf_Sym sym;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2004
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2005
	if (wsp->walk_addr != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2006
		mdb_warn("spa walk only supports global walks\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2007
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2008
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2009
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2010
	if (mdb_lookup_by_obj(ZFS_OBJ_NAME, "spa_namespace_avl", &sym) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2011
		mdb_warn("failed to find symbol 'spa_namespace_avl'");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2012
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2013
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2014
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2015
	wsp->walk_addr = (uintptr_t)sym.st_value;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2016
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2017
	if (mdb_layered_walk("avl", wsp) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2018
		mdb_warn("failed to walk 'avl'\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2019
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2020
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2021
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2022
	return (WALK_NEXT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2023
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2024
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2025
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2026
spa_walk_step(mdb_walk_state_t *wsp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2027
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2028
	spa_t	spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2029
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2030
	if (mdb_vread(&spa, sizeof (spa), wsp->walk_addr) == -1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2031
		mdb_warn("failed to read spa_t at %p", wsp->walk_addr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2032
		return (WALK_ERR);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2033
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2034
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2035
	return (wsp->walk_callback(wsp->walk_addr, &spa, wsp->walk_cbdata));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2036
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2037
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2038
/*
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2039
 * [addr]::walk zio
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2040
 *
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2041
 * 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
  2042
 * 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
  2043
 * structures to a particular pool.
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2044
 */
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2045
static int
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2046
zio_walk_init(mdb_walk_state_t *wsp)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2047
{
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2048
	wsp->walk_data = (void *)wsp->walk_addr;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2049
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2050
	if (mdb_layered_walk("zio_cache", wsp) == -1) {
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2051
		mdb_warn("failed to walk 'zio_cache'\n");
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2052
		return (WALK_ERR);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2053
	}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2054
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2055
	return (WALK_NEXT);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2056
}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2057
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2058
static int
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2059
zio_walk_step(mdb_walk_state_t *wsp)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2060
{
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2061
	zio_t zio;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2062
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2063
	if (mdb_vread(&zio, sizeof (zio), wsp->walk_addr) == -1) {
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2064
		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
  2065
		return (WALK_ERR);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2066
	}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2067
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2068
	if (wsp->walk_data != NULL && wsp->walk_data != zio.io_spa)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2069
		return (WALK_NEXT);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2070
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2071
	return (wsp->walk_callback(wsp->walk_addr, &zio, wsp->walk_cbdata));
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2072
}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2073
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2074
/*
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2075
 * [addr]::walk zio_root
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2076
 *
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2077
 * 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
  2078
 */
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2079
static int
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2080
zio_walk_root_step(mdb_walk_state_t *wsp)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2081
{
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2082
	zio_t zio;
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2083
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2084
	if (mdb_vread(&zio, sizeof (zio), wsp->walk_addr) == -1) {
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2085
		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
  2086
		return (WALK_ERR);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2087
	}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2088
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2089
	if (wsp->walk_data != NULL && wsp->walk_data != zio.io_spa)
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2090
		return (WALK_NEXT);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2091
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2092
	/* If the parent list is not empty, ignore */
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2093
	if (zio.io_parent_list.list_head.list_next !=
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2094
	    &((zio_t *)wsp->walk_addr)->io_parent_list.list_head)
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2095
		return (WALK_NEXT);
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2096
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2097
	return (wsp->walk_callback(wsp->walk_addr, &zio, wsp->walk_cbdata));
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2098
}
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2099
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2100
#define	NICENUM_BUFLEN 6
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2101
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2102
static int
7846
a07ebe2d4dfa 6725668 want ::zfs_blkstats to show block type stats after scrub (fix kmdb)
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7837
diff changeset
  2103
snprintfrac(char *buf, int len,
a07ebe2d4dfa 6725668 want ::zfs_blkstats to show block type stats after scrub (fix kmdb)
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7837
diff changeset
  2104
    uint64_t numerator, uint64_t denom, int frac_digits)
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2105
{
7846
a07ebe2d4dfa 6725668 want ::zfs_blkstats to show block type stats after scrub (fix kmdb)
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7837
diff changeset
  2106
	int mul = 1;
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2107
	int whole, frac, i;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2108
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2109
	for (i = frac_digits; i; i--)
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2110
		mul *= 10;
7846
a07ebe2d4dfa 6725668 want ::zfs_blkstats to show block type stats after scrub (fix kmdb)
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7837
diff changeset
  2111
	whole = numerator / denom;
a07ebe2d4dfa 6725668 want ::zfs_blkstats to show block type stats after scrub (fix kmdb)
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7837
diff changeset
  2112
	frac = mul * numerator / denom - mul * whole;
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2113
	return (mdb_snprintf(buf, len, "%u.%0*u", whole, frac_digits, frac));
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2114
}
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2115
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2116
static void
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2117
mdb_nicenum(uint64_t num, char *buf)
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2118
{
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2119
	uint64_t n = num;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2120
	int index = 0;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2121
	char *u;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2122
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2123
	while (n >= 1024) {
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2124
		n = (n + (1024 / 2)) / 1024; /* Round up or down */
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2125
		index++;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2126
	}
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2127
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2128
	u = &" \0K\0M\0G\0T\0P\0E\0"[index*2];
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2129
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2130
	if (index == 0) {
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2131
		(void) mdb_snprintf(buf, NICENUM_BUFLEN, "%llu",
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2132
		    (u_longlong_t)n);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2133
	} else if (n < 10 && (num & (num - 1)) != 0) {
7846
a07ebe2d4dfa 6725668 want ::zfs_blkstats to show block type stats after scrub (fix kmdb)
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7837
diff changeset
  2134
		(void) snprintfrac(buf, NICENUM_BUFLEN,
a07ebe2d4dfa 6725668 want ::zfs_blkstats to show block type stats after scrub (fix kmdb)
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7837
diff changeset
  2135
		    num, 1ULL << 10 * index, 2);
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2136
		strcat(buf, u);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2137
	} else if (n < 100 && (num & (num - 1)) != 0) {
7846
a07ebe2d4dfa 6725668 want ::zfs_blkstats to show block type stats after scrub (fix kmdb)
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7837
diff changeset
  2138
		(void) snprintfrac(buf, NICENUM_BUFLEN,
a07ebe2d4dfa 6725668 want ::zfs_blkstats to show block type stats after scrub (fix kmdb)
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7837
diff changeset
  2139
		    num, 1ULL << 10 * index, 1);
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2140
		strcat(buf, u);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2141
	} else {
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2142
		(void) mdb_snprintf(buf, NICENUM_BUFLEN, "%llu%s",
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2143
		    (u_longlong_t)n, u);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2144
	}
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2145
}
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2146
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2147
/*
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2148
 * ::zfs_blkstats
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2149
 *
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2150
 * 	-v	print verbose per-level information
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2151
 *
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2152
 */
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2153
static int
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2154
zfs_blkstats(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2155
{
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2156
	boolean_t verbose = B_FALSE;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2157
	zfs_all_blkstats_t stats;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2158
	dmu_object_type_t t;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2159
	zfs_blkstat_t *tzb;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2160
	uint64_t ditto;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2161
	dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES + 10];
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2162
	/* +10 in case it grew */
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2163
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2164
	if (mdb_readvar(&dmu_ot, "dmu_ot") == -1) {
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2165
		mdb_warn("failed to read 'dmu_ot'");
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2166
		return (DCMD_ERR);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2167
	}
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2168
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2169
	if (mdb_getopts(argc, argv,
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2170
	    'v', MDB_OPT_SETBITS, TRUE, &verbose,
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2171
	    NULL) != argc)
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2172
		return (DCMD_USAGE);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2173
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2174
	if (!(flags & DCMD_ADDRSPEC))
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2175
		return (DCMD_USAGE);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2176
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2177
	if (GETMEMB(addr, struct spa, spa_dsl_pool, addr) ||
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2178
	    GETMEMB(addr, struct dsl_pool, dp_blkstats, addr) ||
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2179
	    mdb_vread(&stats, sizeof (zfs_all_blkstats_t), addr) == -1) {
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2180
		mdb_warn("failed to read data at %p;", addr);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2181
		mdb_printf("maybe no stats? run \"zpool scrub\" first.");
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2182
		return (DCMD_ERR);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2183
	}
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2184
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2185
	tzb = &stats.zab_type[DN_MAX_LEVELS][DMU_OT_NUMTYPES];
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2186
	if (tzb->zb_gangs != 0) {
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2187
		mdb_printf("Ganged blocks: %llu\n",
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2188
		    (longlong_t)tzb->zb_gangs);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2189
	}
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2190
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2191
	ditto = tzb->zb_ditto_2_of_2_samevdev + tzb->zb_ditto_2_of_3_samevdev +
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2192
	    tzb->zb_ditto_3_of_3_samevdev;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2193
	if (ditto != 0) {
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2194
		mdb_printf("Dittoed blocks on same vdev: %llu\n",
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2195
		    (longlong_t)ditto);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2196
	}
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2197
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2198
	mdb_printf("\nBlocks\tLSIZE\tPSIZE\tASIZE"
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2199
	    "\t  avg\t comp\t%%Total\tType\n");
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2200
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2201
	for (t = 0; t <= DMU_OT_NUMTYPES; t++) {
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2202
		char csize[NICENUM_BUFLEN], lsize[NICENUM_BUFLEN];
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2203
		char psize[NICENUM_BUFLEN], asize[NICENUM_BUFLEN];
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2204
		char avg[NICENUM_BUFLEN];
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2205
		char comp[NICENUM_BUFLEN], pct[NICENUM_BUFLEN];
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2206
		char typename[64];
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2207
		int l;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2208
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2209
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2210
		if (t == DMU_OT_DEFERRED)
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2211
			strcpy(typename, "deferred free");
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2212
		else if (t == DMU_OT_TOTAL)
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2213
			strcpy(typename, "Total");
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2214
		else if (mdb_readstr(typename, sizeof (typename),
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2215
		    (uintptr_t)dmu_ot[t].ot_name) == -1) {
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2216
			mdb_warn("failed to read type name");
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2217
			return (DCMD_ERR);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2218
		}
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2219
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2220
		if (stats.zab_type[DN_MAX_LEVELS][t].zb_asize == 0)
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2221
			continue;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2222
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2223
		for (l = -1; l < DN_MAX_LEVELS; l++) {
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2224
			int level = (l == -1 ? DN_MAX_LEVELS : l);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2225
			zfs_blkstat_t *zb = &stats.zab_type[level][t];
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2226
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2227
			if (zb->zb_asize == 0)
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2228
				continue;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2229
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2230
			/*
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2231
			 * Don't print each level unless requested.
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2232
			 */
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2233
			if (!verbose && level != DN_MAX_LEVELS)
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2234
				continue;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2235
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2236
			/*
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2237
			 * If all the space is level 0, don't print the
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2238
			 * level 0 separately.
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2239
			 */
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2240
			if (level == 0 && zb->zb_asize ==
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2241
			    stats.zab_type[DN_MAX_LEVELS][t].zb_asize)
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2242
				continue;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2243
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2244
			mdb_nicenum(zb->zb_count, csize);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2245
			mdb_nicenum(zb->zb_lsize, lsize);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2246
			mdb_nicenum(zb->zb_psize, psize);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2247
			mdb_nicenum(zb->zb_asize, asize);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2248
			mdb_nicenum(zb->zb_asize / zb->zb_count, avg);
7846
a07ebe2d4dfa 6725668 want ::zfs_blkstats to show block type stats after scrub (fix kmdb)
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7837
diff changeset
  2249
			(void) snprintfrac(comp, NICENUM_BUFLEN,
a07ebe2d4dfa 6725668 want ::zfs_blkstats to show block type stats after scrub (fix kmdb)
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7837
diff changeset
  2250
			    zb->zb_lsize, zb->zb_psize, 2);
a07ebe2d4dfa 6725668 want ::zfs_blkstats to show block type stats after scrub (fix kmdb)
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7837
diff changeset
  2251
			(void) snprintfrac(pct, NICENUM_BUFLEN,
a07ebe2d4dfa 6725668 want ::zfs_blkstats to show block type stats after scrub (fix kmdb)
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7837
diff changeset
  2252
			    100 * zb->zb_asize, tzb->zb_asize, 2);
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2253
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2254
			mdb_printf("%6s\t%5s\t%5s\t%5s\t%5s"
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2255
			    "\t%5s\t%6s\t",
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2256
			    csize, lsize, psize, asize, avg, comp, pct);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2257
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2258
			if (level == DN_MAX_LEVELS)
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2259
				mdb_printf("%s\n", typename);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2260
			else
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2261
				mdb_printf("  L%d %s\n",
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2262
				    level, typename);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2263
		}
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2264
	}
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2265
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2266
	return (DCMD_OK);
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2267
}
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2268
10407
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2269
/* ARGSUSED */
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2270
static int
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2271
reference_cb(uintptr_t addr, const void *ignored, void *arg)
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2272
{
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2273
	static int gotid;
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2274
	static mdb_ctf_id_t ref_id;
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2275
	uintptr_t ref_holder;
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2276
	uintptr_t ref_removed;
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2277
	uint64_t ref_number;
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
  2278
	boolean_t holder_is_str = B_FALSE;
10407
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2279
	char holder_str[128];
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2280
	boolean_t removed = (boolean_t)arg;
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2281
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2282
	if (!gotid) {
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2283
		if (mdb_ctf_lookup_by_name("struct reference", &ref_id) == -1) {
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2284
			mdb_warn("couldn't find struct reference");
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2285
			return (WALK_ERR);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2286
		}
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2287
		gotid = TRUE;
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2288
	}
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2289
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2290
	if (GETMEMBID(addr, &ref_id, ref_holder, ref_holder) ||
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2291
	    GETMEMBID(addr, &ref_id, ref_removed, ref_removed) ||
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2292
	    GETMEMBID(addr, &ref_id, ref_number, ref_number))
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2293
		return (WALK_ERR);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2294
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
  2295
	if (mdb_readstr(holder_str, sizeof (holder_str), ref_holder) != -1)
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
  2296
		holder_is_str = strisprint(holder_str);
10407
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2297
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2298
	if (removed)
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2299
		mdb_printf("removed ");
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2300
	mdb_printf("reference ");
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2301
	if (ref_number != 1)
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2302
		mdb_printf("with count=%llu ", ref_number);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2303
	mdb_printf("with tag %p", (void*)ref_holder);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2304
	if (holder_is_str)
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2305
		mdb_printf(" \"%s\"", holder_str);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2306
	mdb_printf(", held at:\n");
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2307
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2308
	(void) mdb_call_dcmd("whatis", addr, DCMD_ADDRSPEC, 0, NULL);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2309
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2310
	if (removed) {
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2311
		mdb_printf("removed at:\n");
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2312
		(void) mdb_call_dcmd("whatis", ref_removed,
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2313
		    DCMD_ADDRSPEC, 0, NULL);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2314
	}
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2315
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2316
	mdb_printf("\n");
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2317
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2318
	return (WALK_NEXT);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2319
}
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2320
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2321
/* ARGSUSED */
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2322
static int
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2323
refcount(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2324
{
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2325
	uint64_t rc_count, rc_removed_count;
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2326
	uintptr_t rc_list, rc_removed;
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2327
	static int gotid;
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2328
	static mdb_ctf_id_t rc_id;
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2329
	ulong_t off;
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2330
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2331
	if (!(flags & DCMD_ADDRSPEC))
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2332
		return (DCMD_USAGE);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2333
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2334
	if (!gotid) {
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2335
		if (mdb_ctf_lookup_by_name("struct refcount", &rc_id) == -1) {
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2336
			mdb_warn("couldn't find struct refcount");
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2337
			return (DCMD_ERR);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2338
		}
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2339
		gotid = TRUE;
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2340
	}
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2341
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2342
	if (GETMEMBID(addr, &rc_id, rc_count, rc_count) ||
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2343
	    GETMEMBID(addr, &rc_id, rc_removed_count, rc_removed_count))
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2344
		return (DCMD_ERR);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2345
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2346
	mdb_printf("refcount_t at %p has %llu current holds, "
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2347
	    "%llu recently released holds\n",
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2348
	    addr, (longlong_t)rc_count, (longlong_t)rc_removed_count);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2349
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2350
	if (rc_count > 0)
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2351
		mdb_printf("current holds:\n");
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2352
	if (mdb_ctf_offsetof(rc_id, "rc_list", &off) == -1)
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2353
		return (DCMD_ERR);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2354
	rc_list = addr + off/NBBY;
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2355
	mdb_pwalk("list", reference_cb, (void*)B_FALSE, rc_list);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2356
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2357
	if (rc_removed_count > 0)
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2358
		mdb_printf("released holds:\n");
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2359
	if (mdb_ctf_offsetof(rc_id, "rc_removed", &off) == -1)
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2360
		return (DCMD_ERR);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2361
	rc_removed = addr + off/NBBY;
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2362
	mdb_pwalk("list", reference_cb, (void*)B_TRUE, rc_removed);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2363
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2364
	return (DCMD_OK);
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2365
}
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  2366
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2367
/* ARGSUSED */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2368
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2369
sa_attr_table(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2370
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2371
	sa_attr_table_t *table;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2372
	sa_os_t sa_os;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2373
	char *name;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2374
	int i;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2375
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2376
	if (mdb_vread(&sa_os, sizeof (sa_os_t), addr) == -1) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2377
		mdb_warn("failed to read sa_os at %p", addr);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2378
		return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2379
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2380
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2381
	table = mdb_alloc(sizeof (sa_attr_table_t) * sa_os.sa_num_attrs,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2382
	    UM_SLEEP | UM_GC);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2383
	name = mdb_alloc(MAXPATHLEN, UM_SLEEP | UM_GC);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2384
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2385
	if (mdb_vread(table, sizeof (sa_attr_table_t) * sa_os.sa_num_attrs,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2386
	    (uintptr_t)sa_os.sa_attr_table) == -1) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2387
		mdb_warn("failed to read sa_os at %p", addr);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2388
		return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2389
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2390
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2391
	mdb_printf("%<u>%-10s %-10s %-10s %-10s %s%</u>\n",
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2392
	    "ATTR ID", "REGISTERED", "LENGTH", "BSWAP", "NAME");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2393
	for (i = 0; i != sa_os.sa_num_attrs; i++) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2394
		mdb_readstr(name, MAXPATHLEN, (uintptr_t)table[i].sa_name);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2395
		mdb_printf("%5x   %8x %8x %8x          %-s\n",
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2396
		    (int)table[i].sa_attr, (int)table[i].sa_registered,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2397
		    (int)table[i].sa_length, table[i].sa_byteswap, name);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2398
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2399
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2400
	return (DCMD_OK);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2401
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2402
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2403
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2404
sa_get_off_table(uintptr_t addr, uint32_t **off_tab, int attr_count)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2405
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2406
	uintptr_t idx_table;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2407
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2408
	if (GETMEMB(addr, struct sa_idx_tab, sa_idx_tab, idx_table)) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2409
		mdb_printf("can't find offset table in sa_idx_tab\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2410
		return (-1);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2411
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2412
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2413
	*off_tab = mdb_alloc(attr_count * sizeof (uint32_t),
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2414
	    UM_SLEEP | UM_GC);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2415
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2416
	if (mdb_vread(*off_tab,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2417
	    attr_count * sizeof (uint32_t), idx_table) == -1) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2418
		mdb_warn("failed to attribute offset table %p", idx_table);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2419
		return (-1);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2420
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2421
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2422
	return (DCMD_OK);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2423
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2424
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2425
/*ARGSUSED*/
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2426
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2427
sa_attr_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2428
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2429
	uint32_t *offset_tab;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2430
	int attr_count;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2431
	uint64_t attr_id;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2432
	uintptr_t attr_addr;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2433
	uintptr_t bonus_tab, spill_tab;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2434
	uintptr_t db_bonus, db_spill;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2435
	uintptr_t os, os_sa;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2436
	uintptr_t db_data;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2437
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2438
	if (argc != 1)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2439
		return (DCMD_USAGE);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2440
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2441
	if (argv[0].a_type == MDB_TYPE_STRING)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2442
		attr_id = mdb_strtoull(argv[0].a_un.a_str);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2443
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2444
		return (DCMD_USAGE);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2445
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2446
	if (GETMEMB(addr, struct sa_handle, sa_bonus_tab, bonus_tab) ||
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2447
	    GETMEMB(addr, struct sa_handle, sa_spill_tab, spill_tab) ||
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2448
	    GETMEMB(addr, struct sa_handle, sa_os, os) ||
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2449
	    GETMEMB(addr, struct sa_handle, sa_bonus, db_bonus) ||
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2450
	    GETMEMB(addr, struct sa_handle, sa_spill, db_spill)) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2451
		mdb_printf("Can't find necessary information in sa_handle "
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2452
		    "in sa_handle\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2453
		return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2454
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2455
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2456
	if (GETMEMB(os, struct objset, os_sa, os_sa)) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2457
		mdb_printf("Can't find os_sa in objset\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2458
		return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2459
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2460
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2461
	if (GETMEMB(os_sa, struct sa_os, sa_num_attrs, attr_count)) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2462
		mdb_printf("Can't find sa_num_attrs\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2463
		return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2464
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2465
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2466
	if (attr_id > attr_count) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2467
		mdb_printf("attribute id number is out of range\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2468
		return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2469
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2470
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2471
	if (bonus_tab) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2472
		if (sa_get_off_table(bonus_tab, &offset_tab,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2473
		    attr_count) == -1) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2474
			return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2475
		}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2476
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2477
		if (GETMEMB(db_bonus, struct dmu_buf, db_data, db_data)) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2478
			mdb_printf("can't find db_data in bonus dbuf\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2479
			return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2480
		}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2481
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2482
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2483
	if (bonus_tab && !TOC_ATTR_PRESENT(offset_tab[attr_id]) &&
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2484
	    spill_tab == NULL) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2485
		mdb_printf("Attribute does not exist\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2486
		return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2487
	} else if (!TOC_ATTR_PRESENT(offset_tab[attr_id]) && spill_tab) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2488
		if (sa_get_off_table(spill_tab, &offset_tab,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2489
		    attr_count) == -1) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2490
			return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2491
		}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2492
		if (GETMEMB(db_spill, struct dmu_buf, db_data, db_data)) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2493
			mdb_printf("can't find db_data in spill dbuf\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2494
			return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2495
		}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2496
		if (!TOC_ATTR_PRESENT(offset_tab[attr_id])) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2497
			mdb_printf("Attribute does not exist\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2498
			return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2499
		}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2500
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2501
	attr_addr = db_data + TOC_OFF(offset_tab[attr_id]);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2502
	mdb_printf("%p\n", attr_addr);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2503
	return (DCMD_OK);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2504
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2505
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2506
/* ARGSUSED */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2507
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2508
zfs_ace_print_common(uintptr_t addr, uint_t flags,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2509
    uint64_t id, uint32_t access_mask, uint16_t ace_flags,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2510
    uint16_t ace_type, int verbose)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2511
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2512
	if (DCMD_HDRSPEC(flags) && !verbose)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2513
		mdb_printf("%<u>%-?s %-8s %-8s %-8s %s%</u>\n",
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2514
		    "ADDR", "FLAGS", "MASK", "TYPE", "ID");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2515
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2516
	if (!verbose) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2517
		mdb_printf("%0?p %-8x %-8x %-8x %-llx\n", addr,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2518
		    ace_flags, access_mask, ace_type, id);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2519
		return (DCMD_OK);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2520
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2521
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2522
	switch (ace_flags & ACE_TYPE_FLAGS) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2523
	case ACE_OWNER:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2524
		mdb_printf("owner@:");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2525
		break;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2526
	case (ACE_IDENTIFIER_GROUP | ACE_GROUP):
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2527
		mdb_printf("group@:");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2528
		break;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2529
	case ACE_EVERYONE:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2530
		mdb_printf("everyone@:");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2531
		break;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2532
	case ACE_IDENTIFIER_GROUP:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2533
		mdb_printf("group:%llx:", (u_longlong_t)id);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2534
		break;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2535
	case 0: /* User entry */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2536
		mdb_printf("user:%llx:", (u_longlong_t)id);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2537
		break;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2538
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2539
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2540
	/* print out permission mask */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2541
	if (access_mask & ACE_READ_DATA)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2542
		mdb_printf("r");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2543
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2544
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2545
	if (access_mask & ACE_WRITE_DATA)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2546
		mdb_printf("w");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2547
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2548
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2549
	if (access_mask & ACE_EXECUTE)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2550
		mdb_printf("x");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2551
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2552
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2553
	if (access_mask & ACE_APPEND_DATA)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2554
		mdb_printf("p");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2555
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2556
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2557
	if (access_mask & ACE_DELETE)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2558
		mdb_printf("d");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2559
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2560
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2561
	if (access_mask & ACE_DELETE_CHILD)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2562
		mdb_printf("D");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2563
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2564
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2565
	if (access_mask & ACE_READ_ATTRIBUTES)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2566
		mdb_printf("a");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2567
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2568
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2569
	if (access_mask & ACE_WRITE_ATTRIBUTES)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2570
		mdb_printf("A");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2571
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2572
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2573
	if (access_mask & ACE_READ_NAMED_ATTRS)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2574
		mdb_printf("R");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2575
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2576
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2577
	if (access_mask & ACE_WRITE_NAMED_ATTRS)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2578
		mdb_printf("W");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2579
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2580
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2581
	if (access_mask & ACE_READ_ACL)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2582
		mdb_printf("c");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2583
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2584
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2585
	if (access_mask & ACE_WRITE_ACL)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2586
		mdb_printf("C");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2587
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2588
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2589
	if (access_mask & ACE_WRITE_OWNER)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2590
		mdb_printf("o");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2591
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2592
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2593
	if (access_mask & ACE_SYNCHRONIZE)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2594
		mdb_printf("s");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2595
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2596
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2597
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2598
	mdb_printf(":");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2599
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2600
	/* Print out inheritance flags */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2601
	if (ace_flags & ACE_FILE_INHERIT_ACE)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2602
		mdb_printf("f");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2603
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2604
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2605
	if (ace_flags & ACE_DIRECTORY_INHERIT_ACE)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2606
		mdb_printf("d");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2607
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2608
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2609
	if (ace_flags & ACE_INHERIT_ONLY_ACE)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2610
		mdb_printf("i");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2611
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2612
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2613
	if (ace_flags & ACE_NO_PROPAGATE_INHERIT_ACE)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2614
		mdb_printf("n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2615
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2616
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2617
	if (ace_flags & ACE_SUCCESSFUL_ACCESS_ACE_FLAG)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2618
		mdb_printf("S");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2619
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2620
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2621
	if (ace_flags & ACE_FAILED_ACCESS_ACE_FLAG)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2622
		mdb_printf("F");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2623
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2624
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2625
	if (ace_flags & ACE_INHERITED_ACE)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2626
		mdb_printf("I");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2627
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2628
		mdb_printf("-");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2629
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2630
	switch (ace_type) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2631
	case ACE_ACCESS_ALLOWED_ACE_TYPE:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2632
		mdb_printf(":allow\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2633
		break;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2634
	case ACE_ACCESS_DENIED_ACE_TYPE:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2635
		mdb_printf(":deny\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2636
		break;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2637
	case ACE_SYSTEM_AUDIT_ACE_TYPE:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2638
		mdb_printf(":audit\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2639
		break;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2640
	case ACE_SYSTEM_ALARM_ACE_TYPE:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2641
		mdb_printf(":alarm\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2642
		break;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2643
	default:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2644
		mdb_printf(":?\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2645
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2646
	return (DCMD_OK);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2647
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2648
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2649
/* ARGSUSED */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2650
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2651
zfs_ace_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2652
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2653
	zfs_ace_t zace;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2654
	int verbose = FALSE;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2655
	uint64_t id;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2656
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2657
	if (!(flags & DCMD_ADDRSPEC))
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2658
		return (DCMD_USAGE);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2659
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2660
	if (mdb_getopts(argc, argv,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2661
	    'v', MDB_OPT_SETBITS, TRUE, &verbose, TRUE, NULL) != argc)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2662
		return (DCMD_USAGE);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2663
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2664
	if (mdb_vread(&zace, sizeof (zfs_ace_t), addr) == -1) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2665
		mdb_warn("failed to read zfs_ace_t");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2666
		return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2667
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2668
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2669
	if ((zace.z_hdr.z_flags & ACE_TYPE_FLAGS) == 0 ||
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2670
	    (zace.z_hdr.z_flags & ACE_TYPE_FLAGS) == ACE_IDENTIFIER_GROUP)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2671
		id = zace.z_fuid;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2672
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2673
		id = -1;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2674
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2675
	return (zfs_ace_print_common(addr, flags, id, zace.z_hdr.z_access_mask,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2676
	    zace.z_hdr.z_flags, zace.z_hdr.z_type, verbose));
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2677
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2678
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2679
/* ARGSUSED */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2680
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2681
zfs_ace0_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2682
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2683
	ace_t ace;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2684
	uint64_t id;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2685
	int verbose = FALSE;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2686
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2687
	if (!(flags & DCMD_ADDRSPEC))
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2688
		return (DCMD_USAGE);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2689
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2690
	if (mdb_getopts(argc, argv,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2691
	    'v', MDB_OPT_SETBITS, TRUE, &verbose, TRUE, NULL) != argc)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2692
		return (DCMD_USAGE);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2693
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2694
	if (mdb_vread(&ace, sizeof (ace_t), addr) == -1) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2695
		mdb_warn("failed to read ace_t");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2696
		return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2697
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2698
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2699
	if ((ace.a_flags & ACE_TYPE_FLAGS) == 0 ||
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2700
	    (ace.a_flags & ACE_TYPE_FLAGS) == ACE_IDENTIFIER_GROUP)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2701
		id = ace.a_who;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2702
	else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2703
		id = -1;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2704
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2705
	return (zfs_ace_print_common(addr, flags, id, ace.a_access_mask,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2706
	    ace.a_flags, ace.a_type, verbose));
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2707
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2708
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2709
typedef struct acl_dump_args {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2710
	int a_argc;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2711
	const mdb_arg_t *a_argv;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2712
	uint16_t a_version;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2713
	int a_flags;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2714
} acl_dump_args_t;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2715
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2716
/* ARGSUSED */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2717
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2718
acl_aces_cb(uintptr_t addr, const void *unknown, void *arg)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2719
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2720
	acl_dump_args_t *acl_args = (acl_dump_args_t *)arg;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2721
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2722
	if (acl_args->a_version == 1) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2723
		if (mdb_call_dcmd("zfs_ace", addr,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2724
		    DCMD_ADDRSPEC|acl_args->a_flags, acl_args->a_argc,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2725
		    acl_args->a_argv) != DCMD_OK) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2726
			return (WALK_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2727
		}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2728
	} else {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2729
		if (mdb_call_dcmd("zfs_ace0", addr,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2730
		    DCMD_ADDRSPEC|acl_args->a_flags, acl_args->a_argc,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2731
		    acl_args->a_argv) != DCMD_OK) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2732
			return (WALK_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2733
		}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2734
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2735
	acl_args->a_flags = DCMD_LOOP;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2736
	return (WALK_NEXT);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2737
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2738
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2739
/* ARGSUSED */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2740
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2741
acl_cb(uintptr_t addr, const void *unknown, void *arg)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2742
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2743
	acl_dump_args_t *acl_args = (acl_dump_args_t *)arg;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2744
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2745
	if (acl_args->a_version == 1) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2746
		if (mdb_pwalk("zfs_acl_node_aces", acl_aces_cb,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2747
		    arg, addr) != 0) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2748
			mdb_warn("can't walk ACEs");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2749
			return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2750
		}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2751
	} else {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2752
		if (mdb_pwalk("zfs_acl_node_aces0", acl_aces_cb,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2753
		    arg, addr) != 0) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2754
			mdb_warn("can't walk ACEs");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2755
			return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2756
		}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2757
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2758
	return (WALK_NEXT);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2759
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2760
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2761
/* ARGSUSED */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2762
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2763
zfs_acl_dump(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2764
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2765
	zfs_acl_t zacl;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2766
	int verbose = FALSE;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2767
	acl_dump_args_t acl_args;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2768
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2769
	if (!(flags & DCMD_ADDRSPEC))
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2770
		return (DCMD_USAGE);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2771
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2772
	if (mdb_getopts(argc, argv,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2773
	    'v', MDB_OPT_SETBITS, TRUE, &verbose, TRUE, NULL) != argc)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2774
		return (DCMD_USAGE);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2775
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2776
	if (mdb_vread(&zacl, sizeof (zfs_acl_t), addr) == -1) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2777
		mdb_warn("failed to read zfs_acl_t");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2778
		return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2779
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2780
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2781
	acl_args.a_argc = argc;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2782
	acl_args.a_argv = argv;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2783
	acl_args.a_version = zacl.z_version;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2784
	acl_args.a_flags = DCMD_LOOPFIRST;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2785
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2786
	if (mdb_pwalk("zfs_acl_node", acl_cb, &acl_args, addr) != 0) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2787
		mdb_warn("can't walk ACL");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2788
		return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2789
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2790
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2791
	return (DCMD_OK);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2792
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2793
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2794
/* ARGSUSED */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2795
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2796
zfs_acl_node_walk_init(mdb_walk_state_t *wsp)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2797
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2798
	if (wsp->walk_addr == NULL) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2799
		mdb_warn("must supply address of zfs_acl_node_t\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2800
		return (WALK_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2801
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2802
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2803
	wsp->walk_addr += OFFSETOF(zfs_acl_t, z_acl);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2804
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2805
	if (mdb_layered_walk("list", wsp) == -1) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2806
		mdb_warn("failed to walk 'list'\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2807
		return (WALK_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2808
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2809
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2810
	return (WALK_NEXT);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2811
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2812
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2813
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2814
zfs_acl_node_walk_step(mdb_walk_state_t *wsp)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2815
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2816
	zfs_acl_node_t	aclnode;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2817
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2818
	if (mdb_vread(&aclnode, sizeof (zfs_acl_node_t),
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2819
	    wsp->walk_addr) == -1) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2820
		mdb_warn("failed to read zfs_acl_node at %p", wsp->walk_addr);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2821
		return (WALK_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2822
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2823
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2824
	return (wsp->walk_callback(wsp->walk_addr, &aclnode, wsp->walk_cbdata));
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2825
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2826
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2827
typedef struct ace_walk_data {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2828
	int		ace_count;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2829
	int		ace_version;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2830
} ace_walk_data_t;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2831
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2832
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2833
zfs_aces_walk_init_common(mdb_walk_state_t *wsp, int version,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2834
    int ace_count, uintptr_t ace_data)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2835
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2836
	ace_walk_data_t *ace_walk_data;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2837
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2838
	if (wsp->walk_addr == NULL) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2839
		mdb_warn("must supply address of zfs_acl_node_t\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2840
		return (WALK_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2841
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2842
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2843
	ace_walk_data = mdb_alloc(sizeof (ace_walk_data_t), UM_SLEEP | UM_GC);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2844
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2845
	ace_walk_data->ace_count = ace_count;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2846
	ace_walk_data->ace_version = version;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2847
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2848
	wsp->walk_addr = ace_data;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2849
	wsp->walk_data = ace_walk_data;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2850
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2851
	return (WALK_NEXT);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2852
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2853
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2854
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2855
zfs_acl_node_aces_walk_init_common(mdb_walk_state_t *wsp, int version)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2856
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2857
	static int gotid;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2858
	static mdb_ctf_id_t acl_id;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2859
	int z_ace_count;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2860
	uintptr_t z_acldata;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2861
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2862
	if (!gotid) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2863
		if (mdb_ctf_lookup_by_name("struct zfs_acl_node",
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2864
		    &acl_id) == -1) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2865
			mdb_warn("couldn't find struct zfs_acl_node");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2866
			return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2867
		}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2868
		gotid = TRUE;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2869
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2870
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2871
	if (GETMEMBID(wsp->walk_addr, &acl_id, z_ace_count, z_ace_count)) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2872
		return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2873
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2874
	if (GETMEMBID(wsp->walk_addr, &acl_id, z_acldata, z_acldata)) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2875
		return (DCMD_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2876
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2877
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2878
	return (zfs_aces_walk_init_common(wsp, version,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2879
	    z_ace_count, z_acldata));
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2880
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2881
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2882
/* ARGSUSED */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2883
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2884
zfs_acl_node_aces_walk_init(mdb_walk_state_t *wsp)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2885
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2886
	return (zfs_acl_node_aces_walk_init_common(wsp, 1));
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2887
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2888
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2889
/* ARGSUSED */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2890
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2891
zfs_acl_node_aces0_walk_init(mdb_walk_state_t *wsp)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2892
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2893
	return (zfs_acl_node_aces_walk_init_common(wsp, 0));
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2894
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2895
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2896
static int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2897
zfs_aces_walk_step(mdb_walk_state_t *wsp)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2898
{
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2899
	ace_walk_data_t *ace_data = wsp->walk_data;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2900
	zfs_ace_t zace;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2901
	ace_t *acep;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2902
	int status;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2903
	int entry_type;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2904
	int allow_type;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2905
	uintptr_t ptr;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2906
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2907
	if (ace_data->ace_count == 0)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2908
		return (WALK_DONE);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2909
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2910
	if (mdb_vread(&zace, sizeof (zfs_ace_t), wsp->walk_addr) == -1) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2911
		mdb_warn("failed to read zfs_ace_t at %#lx",
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2912
		    wsp->walk_addr);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2913
		return (WALK_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2914
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2915
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2916
	switch (ace_data->ace_version) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2917
	case 0:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2918
		acep = (ace_t *)&zace;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2919
		entry_type = acep->a_flags & ACE_TYPE_FLAGS;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2920
		allow_type = acep->a_type;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2921
		break;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2922
	case 1:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2923
		entry_type = zace.z_hdr.z_flags & ACE_TYPE_FLAGS;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2924
		allow_type = zace.z_hdr.z_type;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2925
		break;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2926
	default:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2927
		return (WALK_ERR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2928
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2929
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2930
	ptr = (uintptr_t)wsp->walk_addr;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2931
	switch (entry_type) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2932
	case ACE_OWNER:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2933
	case ACE_EVERYONE:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2934
	case (ACE_IDENTIFIER_GROUP | ACE_GROUP):
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2935
		ptr += ace_data->ace_version == 0 ?
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2936
		    sizeof (ace_t) : sizeof (zfs_ace_hdr_t);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2937
		break;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2938
	case ACE_IDENTIFIER_GROUP:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2939
	default:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2940
		switch (allow_type) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2941
		case ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2942
		case ACE_ACCESS_DENIED_OBJECT_ACE_TYPE:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2943
		case ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2944
		case ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2945
			ptr += ace_data->ace_version == 0 ?
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2946
			    sizeof (ace_t) : sizeof (zfs_object_ace_t);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2947
			break;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2948
		default:
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2949
			ptr += ace_data->ace_version == 0 ?
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2950
			    sizeof (ace_t) : sizeof (zfs_ace_t);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2951
			break;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2952
		}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2953
	}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2954
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2955
	ace_data->ace_count--;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2956
	status = wsp->walk_callback(wsp->walk_addr,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2957
	    (void *)(uintptr_t)&zace, wsp->walk_cbdata);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2958
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2959
	wsp->walk_addr = ptr;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2960
	return (status);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2961
}
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  2962
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2963
/*
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2964
 * MDB module linkage information:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2965
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2966
 * We declare a list of structures describing our dcmds, and a function
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2967
 * named _mdb_init to return a pointer to our module information.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2968
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2969
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2970
static const mdb_dcmd_t dcmds[] = {
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
  2971
	{ "arc", "[-bkmg]", "print ARC variables", arc_print },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2972
	{ "blkptr", ":", "print blkptr_t", blkptr },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2973
	{ "dbuf", ":", "print dmu_buf_impl_t", dbuf },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2974
	{ "dbuf_stats", ":", "dbuf stats", dbuf_stats },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2975
	{ "dbufs",
11954
d6630fa76b91 6936265 mismerge in zfs mdb module
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
  2976
	    "\t[-O objset_t*] [-n objset_name | \"mos\"] "
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2977
	    "[-o object | \"mdn\"] \n"
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2978
	    "\t[-l level] [-b blkid | \"bonus\"]",
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2979
	    "find dmu_buf_impl_t's that match specified criteria", dbufs },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2980
	{ "abuf_find", "dva_word[0] dva_word[1]",
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2981
	    "find arc_buf_hdr_t of a specified DVA",
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2982
	    abuf_find },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2983
	{ "spa", "?[-cv]", "spa_t summary", spa_print },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2984
	{ "spa_config", ":", "print spa_t configuration", spa_print_config },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2985
	{ "spa_verify", ":", "verify spa_t consistency", spa_verify },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2986
	{ "spa_space", ":[-b]", "print spa_t on-disk space usage", spa_space },
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  2987
	{ "spa_vdevs", ":", "given a spa_t, print vdev summary", spa_vdevs },
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4451
diff changeset
  2988
	{ "vdev", ":[-re]\n"
8632
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2989
	    "\t-r display recursively\n"
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2990
	    "\t-e print statistics",
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2991
	    "vdev_t summary", vdev_print },
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2992
	{ "zio", ":[cpr]\n"
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2993
	    "\t-c display children\n"
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2994
	    "\t-p display parents\n"
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2995
	    "\t-r display recursively",
36ef517870a3 6798384 It can take a village to raise a zio
Bill Moore <Bill.Moore@Sun.COM>
parents: 8341
diff changeset
  2996
	    "zio_t summary", zio_print },
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2997
	{ "zio_state", "?", "print out all zio_t structures on system or "
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  2998
	    "for a particular pool", zio_state },
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  2999
	{ "zfs_blkstats", ":[-v]",
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  3000
	    "given a spa_t, print block type stats from last scrub",
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
  3001
	    zfs_blkstats },
3059
7d69dbccfcbb 6472021 vdev knobs can not be turned
ahrens
parents: 2885
diff changeset
  3002
	{ "zfs_params", "", "print zfs tunable parameters", zfs_params },
10407
34e10c4af053 6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10298
diff changeset
  3003
	{ "refcount", "", "print refcount_t holders", refcount },
11609
3b5da7ebb54d 6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11422
diff changeset
  3004
	{ "zap_leaf", "", "print zap_leaf_phys_t", zap_leaf },
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  3005
	{ "zfs_aces", ":[-v]", "print all ACEs from a zfs_acl_t",
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  3006
	    zfs_acl_dump },
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  3007
	{ "zfs_ace", ":[-v]", "print zfs_ace", zfs_ace_print },
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  3008
	{ "zfs_ace0", ":[-v]", "print zfs_ace0", zfs_ace0_print },
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  3009
	{ "sa_attr_table", ":", "print SA attribute table from sa_os_t",
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  3010
	    sa_attr_table},
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  3011
	{ "sa_attr", ": attr_id",
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  3012
	    "print SA attribute address when given sa_handle_t", sa_attr_print},
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
  3013
	{ "zfs_dbgmsg", ":[-v]",
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12294
diff changeset
  3014
	    "print zfs debug log", dbgmsg},
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3015
	{ NULL }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3016
};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3017
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3018
static const mdb_walker_t walkers[] = {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3019
	{ "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
  3020
		freelist_walk_init, freelist_walk_step, NULL },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3021
	{ "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
  3022
		txg_list_walk_init, txg_list_walk_step, NULL },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3023
	{ "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
  3024
		txg_list0_walk_init, txg_list_walk_step, NULL },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3025
	{ "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
  3026
		txg_list1_walk_init, txg_list_walk_step, NULL },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3027
	{ "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
  3028
		txg_list2_walk_init, txg_list_walk_step, NULL },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3029
	{ "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
  3030
		txg_list3_walk_init, txg_list_walk_step, NULL },
4055
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  3031
	{ "zio", "walk all zio structures, optionally for a particular spa_t",
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  3032
		zio_walk_init, zio_walk_step, NULL },
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  3033
	{ "zio_root", "walk all root zio_t structures, optionally for a "
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  3034
	    "particular spa_t",
9b8dd5af941d 6536445 want ::zio to show zio tree
eschrock
parents: 3403
diff changeset
  3035
		zio_walk_init, zio_walk_root_step, NULL },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3036
	{ "spa", "walk all spa_t entries in the namespace",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3037
		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
  3038
	{ "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
  3039
		metaslab_walk_init, metaslab_walk_step, NULL },
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  3040
	{ "zfs_acl_node", "given a zfs_acl_t, walk all zfs_acl_nodes",
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  3041
	    zfs_acl_node_walk_init, zfs_acl_node_walk_step, NULL },
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  3042
	{ "zfs_acl_node_aces", "given a zfs_acl_node_t, walk all ACEs",
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  3043
	    zfs_acl_node_aces_walk_init, zfs_aces_walk_step, NULL },
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  3044
	{ "zfs_acl_node_aces0",
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  3045
	    "given a zfs_acl_node_t, walk all ACEs as ace_t",
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11726
diff changeset
  3046
	    zfs_acl_node_aces0_walk_init, zfs_aces_walk_step, NULL },
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3047
	{ NULL }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3048
};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3049
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3050
static const mdb_modinfo_t modinfo = {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3051
	MDB_API_VERSION, dcmds, walkers
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3052
};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3053
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3054
const mdb_modinfo_t *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3055
_mdb_init(void)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3056
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3057
	return (&modinfo);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  3058
}