zdb.c revision fa9e4066f08beec538e775443c5be79dd423fcab
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * CDDL HEADER START
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * The contents of this file are subject to the terms of the
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * Common Development and Distribution License, Version 1.0 only
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * (the "License"). You may not use this file except in compliance
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * with the License.
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * or http://www.opensolaris.org/os/licensing.
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * See the License for the specific language governing permissions
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * and limitations under the License.
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * When distributing Covered Code, include this CDDL HEADER in each
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * If applicable, add the following below this CDDL HEADER, with the
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * fields enclosed by brackets "[]" replaced with your own identifying
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * information: Portions Copyright [yyyy] [name of copyright owner]
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * CDDL HEADER END
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * Use is subject to license terms.
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore#pragma ident "%Z%%M% %I% %E% SMI"
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amoretypedef void object_viewer_t(objset_t *, uint64_t, void *data, size_t size);
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amorezbookmark_t zdb_noread = { 0, 0, ZB_NO_LEVEL, 0 };
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * These libumem hooks provide a reasonable set of defaults for the allocator's
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore * debugging facilities.
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore return ("default,verbose"); /* $UMEM_DEBUG setting */
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore return ("fail,contents"); /* $UMEM_LOGGING setting */
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore "Usage: %s [-udibcsvLU] [-O order] [-B os:obj:level:blkid] "
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore "dataset [object...]\n"
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore " %s -C [pool]\n"
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore " %s -l dev\n",
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore (void) fprintf(stderr, " -C cached pool configuration\n");
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore (void) fprintf(stderr, " -i intent logs\n");
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore (void) fprintf(stderr, " -b block statistics\n");
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore (void) fprintf(stderr, " -c checksum all data blocks\n");
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore (void) fprintf(stderr, " -s report stats on zdb's I/O\n");
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore (void) fprintf(stderr, " -v verbose (applies to all others)\n");
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore (void) fprintf(stderr, " -l dump label contents\n");
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore (void) fprintf(stderr, " -L live pool (allows some errors)\n");
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore (void) fprintf(stderr, " -O [!]<pre|post|prune|data|holes> "
case DATA_TYPE_STRING:
char *value;
case DATA_TYPE_UINT64:
case DATA_TYPE_NVLIST:
case DATA_TYPE_NVLIST_ARRAY:
&count) == 0);
for (c = 0; c < count; c++) {
int maxidx = 0;
for (i = 0; i < ZAP_HISTOGRAM_SIZE; i++) {
maxidx = i;
minidx = i;
int error;
if (error)
void *prop;
alloc = 0;
freebuf);
(void) printf(
if (indent == 0)
static uint64_t
if (level < 0)
return (blkid);
goto out;
fill++;
out:
if (object == 0)
char *path;
return (path);
return (path);
int error;
if (*print_header) {
*print_header = 0;
if (object == 0) {
lsize);
minlvl = 0;
blkfill);
if (error)
blkfill);
if (error)
int i, error;
blkbuf);
if (zopt_objects != 0) {
for (i = 0; i < zopt_objects; i++)
&print_header);
object = 0;
object_count++;
int fd;
for (l = 0; l < VDEV_LABELS; l++) {
int error;
if (error) {
int c, m, error;
if (error)
int error;
return (ENXIO);
return (ENXIO);
if (error)
return (error);
for (g = 0; g < SPA_GBH_NBLKPTRS; g++) {
if (error)
return (error);
typedef struct zdb_blkstats {
typedef struct zdb_cb {
int zcb_readfails;
int zcb_haderrors;
} zdb_cb_t;
int i, error;
if (error == 0)
int error = 0;
return (error);
blkbuf);
int leaks = 0;
int flags;
int l, t, level;
for (t = 0; t <= DMU_OT_NUMTYPES; t++) {
char *typename;
typename);
if (leaks)
int rc = 0;
if (rc != 0)
char *endstr;
int verbose = 0;
int error;
dump_opt[c]++;
dump_all = 0;
dump_opt[c]++;
endstr++;
set = 0;
usage();
if (set)
verbose++;
usage();
if (dump_opt[c])
usage();
if (error)
argv++;
if (--argc > 0) {
for (i = 0; i < zopt_objects; i++) {
errno = 0;
kernel_fini();