fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The contents of this file are subject to the terms of the
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Common Development and Distribution License (the "License").
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * You may not use this file except in compliance with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrens * information: Portions Copyright [yyyy] [name of copyright owner]
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
8f2529de2d60d4fff8eb4d86f71b51584342934eMark Shellenbaum * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
29bdd2f916366ece37c4748bca6b3d61f57a223bPavel Zakharov * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
c3d26abc9ee97b4f60233556aadeb57e0bd30bb9Matthew Ahrens * Copyright (c) 2014 Integros [integros.com]
e690fb27a7d1483f052505e1ff373d205f9dee99Christopher Siden#define ZDB_COMPRESS_NAME(idx) ((idx) < ZIO_COMPRESS_FUNCTIONS ? \
e690fb27a7d1483f052505e1ff373d205f9dee99Christopher Siden zio_compress_table[(idx)].ci_name : "UNKNOWN")
e690fb27a7d1483f052505e1ff373d205f9dee99Christopher Siden#define ZDB_CHECKSUM_NAME(idx) ((idx) < ZIO_CHECKSUM_FUNCTIONS ? \
e690fb27a7d1483f052505e1ff373d205f9dee99Christopher Siden zio_checksum_table[(idx)].ci_name : "UNKNOWN")
e690fb27a7d1483f052505e1ff373d205f9dee99Christopher Siden#define ZDB_OT_NAME(idx) ((idx) < DMU_OT_NUMTYPES ? \
e690fb27a7d1483f052505e1ff373d205f9dee99Christopher Siden dmu_ot[(idx)].ot_name : DMU_OT_IS_VALID(idx) ? \
e690fb27a7d1483f052505e1ff373d205f9dee99Christopher Siden dmu_ot_byteswap[DMU_OT_BYTESWAP(idx)].ob_name : "UNKNOWN")
e690fb27a7d1483f052505e1ff373d205f9dee99Christopher Siden#define ZDB_OT_TYPE(idx) ((idx) < DMU_OT_NUMTYPES ? (idx) : \
e690fb27a7d1483f052505e1ff373d205f9dee99Christopher Siden (((idx) == DMU_OTN_ZAP_DATA || (idx) == DMU_OTN_ZAP_METADATA) ? \
06be98028b8a84e7f327188613dd09a708294d1aMatthew Ahrensextern uint64_t zfs_arc_max, zfs_arc_meta_limit;
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef void object_viewer_t(objset_t *, uint64_t, void *data, size_t size);
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrensstatic void snprintf_blkptr_compact(char *, size_t, const blkptr_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrens * These libumem hooks provide a reasonable set of defaults for the allocator's
fa9e4066f08beec538e775443c5be79dd423fcabahrens * debugging facilities.
fa9e4066f08beec538e775443c5be79dd423fcabahrensconst char *
fa9e4066f08beec538e775443c5be79dd423fcabahrens return ("default,verbose"); /* $UMEM_DEBUG setting */
fa9e4066f08beec538e775443c5be79dd423fcabahrensconst char *
fa9e4066f08beec538e775443c5be79dd423fcabahrens return ("fail,contents"); /* $UMEM_LOGGING setting */
29bdd2f916366ece37c4748bca6b3d61f57a223bPavel Zakharov "Usage: %s [-CumMdibcsDvhLXFPAG] [-t txg] [-e [-p path...]] "
0e60744c982adecd0a1f146f5637475d07ab1069Pavel Zakharov "[-U config] [-I inflight I/Os] [-x dumpdir] [-o var=value] "
0e60744c982adecd0a1f146f5637475d07ab1069Pavel Zakharov "poolname [object...]\n"
31d7e8fa33fae995f558673adb22641b5aa8b6e1George Wilson " %s [-divPA] [-e -p path...] [-U config] dataset "
31d7e8fa33fae995f558673adb22641b5aa8b6e1George Wilson "[object...]\n"
2e4c998613148111f2fc5371085331ffb39122ffGeorge Wilson " %s -mM [-LXFPA] [-t txg] [-e [-p path...]] [-U config] "
90e894e2eeb5dc45bff06b19d393ee7b2d450277Richard Lowe "poolname [vdev [metaslab...]]\n"
90e894e2eeb5dc45bff06b19d393ee7b2d450277Richard Lowe " %s -R [-A] [-e [-p path...]] poolname "
90e894e2eeb5dc45bff06b19d393ee7b2d450277Richard Lowe "vdev:offset:size[:flags]\n"
31d7e8fa33fae995f558673adb22641b5aa8b6e1George Wilson " %s -S [-PA] [-e [-p path...]] [-U config] poolname\n"
90e894e2eeb5dc45bff06b19d393ee7b2d450277Richard Lowe " %s -l [-uA] device\n"
90e894e2eeb5dc45bff06b19d393ee7b2d450277Richard Lowe " %s -C [-A] [-U config]\n\n",
bbfd46c40e81c7d954cec28db66453ec5ab44613Jeff Bonwick cmdname, cmdname, cmdname, cmdname, cmdname, cmdname, cmdname);
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fprintf(stderr, " Dataset name must include at least one "
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin "separator character '/' or '@'\n");
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fprintf(stderr, " If dataset name is specified, only that "
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin "dataset is dumped\n");
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fprintf(stderr, " If object numbers are specified, only "
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin "those objects are dumped\n\n");
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fprintf(stderr, " Options to control amount of output:\n");
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fprintf(stderr, " -d dataset(s)\n");
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fprintf(stderr, " -i intent logs\n");
07428bdfb7bca7c9e74959692785555ea5e27ce2Victor Latushkin (void) fprintf(stderr, " -C config (or cachefile if alone)\n");
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fprintf(stderr, " -b block statistics\n");
2e4c998613148111f2fc5371085331ffb39122ffGeorge Wilson (void) fprintf(stderr, " -M metaslab groups\n");
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fprintf(stderr, " -c checksum all metadata (twice for "
6365109ded948bd19a48c186a43ed08bd46a26adVictor Latushkin "all data) blocks\n");
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fprintf(stderr, " -s report stats on zdb's I/O\n");
f0ba89be159095fb15265a5e1cd79e09e5e44ef9Jeff Bonwick (void) fprintf(stderr, " -D dedup statistics\n");
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) fprintf(stderr, " -S simulate dedup to measure effect\n");
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fprintf(stderr, " -v verbose (applies to all others)\n");
82a0a985b0e8df9eae061303b421d2df27c728f0Victor Latushkin (void) fprintf(stderr, " -L disable leak tracking (do not "
82a0a985b0e8df9eae061303b421d2df27c728f0Victor Latushkin "load spacemaps)\n");
d41e76436a9498c7a8ab1f783125ac49f517eaf9ek (void) fprintf(stderr, " -R read and display block from a "
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin "device\n\n");
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fprintf(stderr, " Below options are intended for use "
df15e419cb7359ba56ddddab9045e438d89e7cbcMatthew Ahrens "with other options:\n");
feef89cf5f5fee792c1a396bb0e48070935cf65aVictor Latushkin (void) fprintf(stderr, " -A ignore assertions (-A), enable "
feef89cf5f5fee792c1a396bb0e48070935cf65aVictor Latushkin "panic recovery (-AA) or both (-AAA)\n");
c8ee1847e300c992c76cf25d6c165e6ccf64a113Victor Latushkin (void) fprintf(stderr, " -F attempt automatic rewind within "
c8ee1847e300c992c76cf25d6c165e6ccf64a113Victor Latushkin "safe range of transaction groups\n");
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fprintf(stderr, " -U <cachefile_path> -- use alternate "
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin "cachefile\n");
c8ee1847e300c992c76cf25d6c165e6ccf64a113Victor Latushkin (void) fprintf(stderr, " -X attempt extreme rewind (does not "
c8ee1847e300c992c76cf25d6c165e6ccf64a113Victor Latushkin "work with dataset)\n");
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fprintf(stderr, " -e pool is exported/destroyed/"
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin "has altroot/not in a cachefile\n");
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fprintf(stderr, " -p <path> -- use one or more with "
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin "-e to specify path to vdev dir\n");
df15e419cb7359ba56ddddab9045e438d89e7cbcMatthew Ahrens "dump all read blocks into specified directory\n");
90e894e2eeb5dc45bff06b19d393ee7b2d450277Richard Lowe (void) fprintf(stderr, " -P print numbers in parseable form\n");
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fprintf(stderr, " -t <txg> -- highest txg to use when "
2e55192768a98297f0a2b4c1b5dbc3f91771ac38Victor Latushkin "searching for uberblocks\n");
2e4c998613148111f2fc5371085331ffb39122ffGeorge Wilson (void) fprintf(stderr, " -I <number of inflight I/Os> -- "
df15e419cb7359ba56ddddab9045e438d89e7cbcMatthew Ahrens "specify the maximum number of "
df15e419cb7359ba56ddddab9045e438d89e7cbcMatthew Ahrens "checksumming I/Os [default is 200]\n");
29bdd2f916366ece37c4748bca6b3d61f57a223bPavel Zakharov (void) fprintf(stderr, " -G dump zfs_dbgmsg buffer before "
29bdd2f916366ece37c4748bca6b3d61f57a223bPavel Zakharov "exiting\n");
0e60744c982adecd0a1f146f5637475d07ab1069Pavel Zakharov (void) fprintf(stderr, " -o <variable>=<value> set global "
0e60744c982adecd0a1f146f5637475d07ab1069Pavel Zakharov "variable to an unsigned 32-bit integer value\n");
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) fprintf(stderr, "Specify an option more than once (e.g. -bb) "
fa9e4066f08beec538e775443c5be79dd423fcabahrens "to make only that option verbose\n");
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) fprintf(stderr, "Default is to dump everything non-verbosely\n");
ccba08015a17f88186762dd6d9f91195adb387e8Rich Morris * Called for usage errors that are discovered after a call to spa_open(),
ccba08015a17f88186762dd6d9f91195adb387e8Rich Morris * dmu_bonus_hold(), or pool_match(). abort() is called for other errors.
fa9e4066f08beec538e775443c5be79dd423fcabahrens/* ARGSUSED */
fa9e4066f08beec538e775443c5be79dd423fcabahrensdump_packed_nvlist(objset_t *os, uint64_t object, void *data, size_t size)
7bfdf011e081684f853a3242d0296695110d9d84Neil Perrin VERIFY(0 == dmu_read(os, object, 0, nvsize, packed, DMU_READ_PREFETCH));
4445fffbbb1ea25fd0e9ea68b9380dd7a6709025Matthew Ahrens/* ARGSUSED */
4445fffbbb1ea25fd0e9ea68b9380dd7a6709025Matthew Ahrensdump_history_offsets(objset_t *os, uint64_t object, void *data, size_t size)
4445fffbbb1ea25fd0e9ea68b9380dd7a6709025Matthew Ahrens (void) printf("\t\tpool_create_len = %llu\n",
490d05b9daa0e60fbb3aac647c556408e88228bdMatthew Ahrensconst char histo_stars[] = "****************************************";
490d05b9daa0e60fbb3aac647c556408e88228bdMatthew Ahrensconst int histo_width = sizeof (histo_stars) - 1;
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilsondump_histogram(const uint64_t *histo, int size, int offset)
490d05b9daa0e60fbb3aac647c556408e88228bdMatthew Ahrens for (i = 0; i < size; i++) {
490d05b9daa0e60fbb3aac647c556408e88228bdMatthew Ahrens &histo_stars[(max - histo[i]) * histo_width / max]);
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) printf("\tmicrozap: %llu bytes, %llu entries\n",
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson dump_histogram(zs.zs_leafs_with_2n_pointers, ZAP_HISTOGRAM_SIZE, 0);
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson dump_histogram(zs.zs_blocks_with_n5_entries, ZAP_HISTOGRAM_SIZE, 0);
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson dump_histogram(zs.zs_blocks_n_tenths_full, ZAP_HISTOGRAM_SIZE, 0);
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson dump_histogram(zs.zs_entries_using_n_chunks, ZAP_HISTOGRAM_SIZE, 0);
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson dump_histogram(zs.zs_buckets_with_n_entries, ZAP_HISTOGRAM_SIZE, 0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*ARGSUSED*/
fa9e4066f08beec538e775443c5be79dd423fcabahrensdump_none(objset_t *os, uint64_t object, void *data, size_t size)
6de8f417ed556c30c2c5d24961e26ca586e636a1Victor Latushkindump_unknown(objset_t *os, uint64_t object, void *data, size_t size)
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*ARGSUSED*/
fa9e4066f08beec538e775443c5be79dd423fcabahrensdump_uint8(objset_t *os, uint64_t object, void *data, size_t size)
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*ARGSUSED*/
fa9e4066f08beec538e775443c5be79dd423fcabahrensdump_uint64(objset_t *os, uint64_t object, void *data, size_t size)
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*ARGSUSED*/
fa9e4066f08beec538e775443c5be79dd423fcabahrensdump_zap(objset_t *os, uint64_t object, void *data, size_t size)
fa9e4066f08beec538e775443c5be79dd423fcabahrens umem_free(prop, attr.za_num_integers * attr.za_integer_length);
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrensdump_bpobj(objset_t *os, uint64_t object, void *data, size_t size)
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrens for (uint64_t i = 0; i < bpop->bpo_num_blkptrs; i++) {
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrens (void) printf("got error %u from dmu_read\n", err);
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrens snprintf_blkptr_compact(blkbuf, sizeof (blkbuf), &bp);
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrens/* ARGSUSED */
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrensdump_bpobj_subobjs(objset_t *os, uint64_t object, void *data, size_t size)
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrens uint64_t *subobjs = kmem_alloc(doi.doi_max_offset, KM_SLEEP);
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrens int err = dmu_read(os, object, 0, doi.doi_max_offset, subobjs, 0);
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrens (void) printf("got error %u from dmu_read\n", err);
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrens for (uint64_t i = 0; i < doi.doi_max_offset / 8; i++) {
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrens for (int64_t i = 0; i <= last_nonzero; i++) {
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrens (void) printf("\t%llu\n", (longlong_t)subobjs[i]);
486ae710326c477d7237ab803b67abb9119c0799Matthew Ahrensdump_ddt_zap(objset_t *os, uint64_t object, void *data, size_t size)
486ae710326c477d7237ab803b67abb9119c0799Matthew Ahrens /* contents are printed elsewhere, properly decoded */
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaumdump_sa_attrs(objset_t *os, uint64_t object, void *data, size_t size)
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaumdump_sa_layouts(objset_t *os, uint64_t object, void *data, size_t size)
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum layout_attrs = umem_zalloc(attr.za_num_integers *
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum VERIFY(zap_lookup(os, object, attr.za_name,
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum for (i = 0; i != attr.za_num_integers; i++)
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum (void) printf(" %d ", (int)layout_attrs[i]);
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum attr.za_num_integers * attr.za_integer_length);
e7437265dc2a4920c197ed4337665539d358b22cahrens/*ARGSUSED*/
e7437265dc2a4920c197ed4337665539d358b22cahrensdump_zpldir(objset_t *os, uint64_t object, void *data, size_t size)
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson sm->sm_dbuf->db_size == sizeof (space_map_phys_t))
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson refcount += get_dtl_refcount(vd->vdev_child[c]);
2e4c998613148111f2fc5371085331ffb39122ffGeorge Wilson if (vd->vdev_top == vd && !vd->vdev_removing) {
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson sm->sm_dbuf->db_size == sizeof (space_map_phys_t))
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson refcount += get_metaslab_refcount(vd->vdev_child[c]);
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens &spa_feature_table[SPA_FEATURE_SPACEMAP_HISTOGRAM],
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson actual_refcount = get_dtl_refcount(spa->spa_root_vdev);
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson actual_refcount += get_metaslab_refcount(spa->spa_root_vdev);
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens (void) printf("space map refcount mismatch: expected %lld != "
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens "actual %lld\n",
8053a26377fa80614ba5221e12b86aab4e8a675eck char *ddata[] = { "ALLOC", "FREE", "CONDENSE", "INVALID",
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Print out the freelist entries in both encoded and decoded form.
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson for (offset = 0; offset < space_map_length(sm);
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson VERIFY0(dmu_read(os, space_map_object(sm), offset,
87219db7f64d5002b5a8311fd76f7900fda2c4e8Victor Latushkin (void) printf("\t [%6llu] %s: txg %llu, pass %llu\n",
87219db7f64d5002b5a8311fd76f7900fda2c4e8Victor Latushkin " %010llx-%010llx size: %06llx\n",
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) printf("space_map_object alloc (%llu) INCONSISTENT "
fa9e4066f08beec538e775443c5be79dd423fcabahrens "with space map summary (%llu)\n",
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson (u_longlong_t)space_map_allocated(sm), (u_longlong_t)alloc);
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson int free_pct = range_tree_space(rt) * 100 / msp->ms_size;
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson zdb_nicenum(metaslab_block_maxsize(msp), maxbuf);
87219db7f64d5002b5a8311fd76f7900fda2c4e8Victor Latushkin (void) printf("\t %25s %10lu %7s %6s %4s %4d%%\n",
d6e555bdd793b8bc8fe57d5f12c3d69c813d0661George Wilson "segments", avl_numnodes(t), "maxsize", maxbuf,
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson dump_histogram(rt->rt_histogram, RANGE_TREE_HISTOGRAM_SIZE, 0);
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson zdb_nicenum(msp->ms_size - space_map_allocated(sm), freebuf);
87219db7f64d5002b5a8311fd76f7900fda2c4e8Victor Latushkin "\tmetaslab %6llu offset %12llx spacemap %6llu free %5s\n",
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson (u_longlong_t)msp->ms_id, (u_longlong_t)msp->ms_start,
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens spa_feature_is_active(spa, SPA_FEATURE_SPACEMAP_HISTOGRAM)) {
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * The space map histogram represents free space in chunks
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * of sm_shift (i.e. bucket 0 refers to 2^sm_shift).
2e4c998613148111f2fc5371085331ffb39122ffGeorge Wilson (void) printf("\tOn-disk histogram:\t\tfragmentation %llu\n",
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson ASSERT(msp->ms_size == (1ULL << vd->vdev_ms_shift));
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson dump_spacemap(spa->spa_meta_objset, msp->ms_sm);
87219db7f64d5002b5a8311fd76f7900fda2c4e8Victor Latushkin (void) printf("\tvdev %10llu\n\t%-10s%5llu %-19s %-15s %-10s\n",
87219db7f64d5002b5a8311fd76f7900fda2c4e8Victor Latushkin "metaslabs", (u_longlong_t)vd->vdev_ms_count,
2e4c998613148111f2fc5371085331ffb39122ffGeorge Wilson for (int c = 0; c < rvd->vdev_children; c++) {
2e4c998613148111f2fc5371085331ffb39122ffGeorge Wilson mg->mg_fragmentation = metaslab_group_fragmentation(mg);
2e4c998613148111f2fc5371085331ffb39122ffGeorge Wilson (void) printf("\tvdev %10llu\t\tmetaslabs%5llu\t\t"
2e4c998613148111f2fc5371085331ffb39122ffGeorge Wilson "fragmentation",
2e4c998613148111f2fc5371085331ffb39122ffGeorge Wilson if (mg->mg_fragmentation == ZFS_FRAG_INVALID) {
2e4c998613148111f2fc5371085331ffb39122ffGeorge Wilson dump_histogram(mg->mg_histogram, RANGE_TREE_HISTOGRAM_SIZE, 0);
2e4c998613148111f2fc5371085331ffb39122ffGeorge Wilson (void) printf("\tpool %s\tfragmentation", spa_name(spa));
2e4c998613148111f2fc5371085331ffb39122ffGeorge Wilson fragmentation = metaslab_class_fragmentation(mc);
2e4c998613148111f2fc5371085331ffb39122ffGeorge Wilson (void) printf("\t%3llu%%\n", (u_longlong_t)fragmentation);
2e4c998613148111f2fc5371085331ffb39122ffGeorge Wilson dump_histogram(mc->mc_histogram, RANGE_TREE_HISTOGRAM_SIZE, 0);
87219db7f64d5002b5a8311fd76f7900fda2c4e8Victor Latushkin uint64_t m, c = 0, children = rvd->vdev_children;
87219db7f64d5002b5a8311fd76f7900fda2c4e8Victor Latushkin (void) fatal("bad vdev id: %llu", (u_longlong_t)c);
87219db7f64d5002b5a8311fd76f7900fda2c4e8Victor Latushkin "number %llu\n",
87219db7f64d5002b5a8311fd76f7900fda2c4e8Victor Latushkin for (; c < children; c++) {
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickdump_dde(const ddt_t *ddt, const ddt_entry_t *dde, uint64_t index)
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick char *types[4] = { "ditto", "single", "double", "triple" };
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick for (int p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
bbfd46c40e81c7d954cec28db66453ec5ab44613Jeff Bonwick ddt_bp_create(ddt->ddt_checksum, ddk, ddp, &blk);
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman snprintf_blkptr(blkbuf, sizeof (blkbuf), &blk);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) printf("index %llx refcnt %llu %s %s\n",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (u_longlong_t)index, (u_longlong_t)ddp->ddp_refcnt,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) printf("dedup = %.2f, compress = %.2f, copies = %.2f, "
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick "dedup * compress / copies = %.2f\n\n",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick dedup, compress, copies, dedup * compress / copies);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickdump_ddt(ddt_t *ddt, enum ddt_type type, enum ddt_class class)
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick error = ddt_object_info(ddt, type, class, &doi);
7448a0795bbf890c55a5c66129a0d606f02a784eGeorge Wilson if ((count = ddt_object_count(ddt, type, class)) == 0)
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick mspace = doi.doi_fill_count * doi.doi_data_block_size;
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) printf("%s: %llu entries, size %llu on disk, %llu in core\n",
9eb19f4d61679ca0382def038665019234458eddGeorge Wilson zpool_dump_ddt(NULL, &ddt->ddt_histogram[type][class]);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick if (dump_opt['D'] < 5 && class == DDT_CLASS_UNIQUE)
bbfd46c40e81c7d954cec28db66453ec5ab44613Jeff Bonwick while ((error = ddt_object_walk(ddt, type, class, &walk, &dde)) == 0)
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) {
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick for (enum ddt_type type = 0; type < DDT_TYPES; type++) {
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick for (enum ddt_class class = 0; class < DDT_CLASSES;
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) printf("DDT histogram (aggregated over all DDTs):\n");
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilsondump_dtl_seg(void *arg, uint64_t start, uint64_t size)
8ad4d6dd86f5bc65fb3afa566c8133f3bac21648Jeff Bonwick char *name[DTL_TYPES] = { "missing", "partial", "scrub", "outage" };
8ad4d6dd86f5bc65fb3afa566c8133f3bac21648Jeff Bonwick vd->vdev_parent ? vd->vdev_ops->vdev_op_type : spa_name(spa),
8ad4d6dd86f5bc65fb3afa566c8133f3bac21648Jeff Bonwick for (int t = 0; t < DTL_TYPES; t++) {
8ad4d6dd86f5bc65fb3afa566c8133f3bac21648Jeff Bonwick (void) snprintf(prefix, sizeof (prefix), "\t%*s%s",
8ad4d6dd86f5bc65fb3afa566c8133f3bac21648Jeff Bonwick if (dump_opt['d'] > 5 && vd->vdev_children == 0)
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson dump_spacemap(spa->spa_meta_objset, vd->vdev_dtl_sm);
3f84190c280ddf5917fb4682f34fdaa328ee195cMatthew Ahrens char *buf = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL);
8f18d1fadf6a0c20fac9ff7259a5368faa3c3bfbGeorge Wilson if ((error = spa_history_get(spa, &off, &len, buf)) != 0) {
8f18d1fadf6a0c20fac9ff7259a5368faa3c3bfbGeorge Wilson (void) fprintf(stderr, "Unable to read history: "
8f18d1fadf6a0c20fac9ff7259a5368faa3c3bfbGeorge Wilson if (zpool_history_unpack(buf, len, &resid, &events, &num) != 0)
8f18d1fadf6a0c20fac9ff7259a5368faa3c3bfbGeorge Wilson } while (len != 0);
8f18d1fadf6a0c20fac9ff7259a5368faa3c3bfbGeorge Wilson for (int i = 0; i < num; i++) {
8f18d1fadf6a0c20fac9ff7259a5368faa3c3bfbGeorge Wilson if (nvlist_lookup_uint64(events[i], ZPOOL_HIST_TIME,
8f18d1fadf6a0c20fac9ff7259a5368faa3c3bfbGeorge Wilson if (nvlist_lookup_string(events[i], ZPOOL_HIST_CMD,
8f18d1fadf6a0c20fac9ff7259a5368faa3c3bfbGeorge Wilson "[internal %s txg:%lld] %s",
8f18d1fadf6a0c20fac9ff7259a5368faa3c3bfbGeorge Wilson (void) strftime(tbuf, sizeof (tbuf), "%F.%T", &t);
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*ARGSUSED*/
fa9e4066f08beec538e775443c5be79dd423fcabahrensdump_dnode(objset_t *os, uint64_t object, void *data, size_t size)
7802d7bf98dec568dadf72286893b1fe5abd8602Matthew Ahrensblkid2offset(const dnode_phys_t *dnp, const blkptr_t *bp,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (zb->zb_level * (dnp->dn_indblkshift - SPA_BLKPTRSHIFT))) *
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossmansnprintf_blkptr_compact(char *blkbuf, size_t buflen, const blkptr_t *bp)
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick int ndvas = dump_opt['d'] > 5 ? BP_GET_NDVAS(bp) : 1;
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens "EMBEDDED et=%u %llxL/%llxP B=%llu",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick for (int i = 0; i < ndvas; i++)
70163ac57e58ace1c5c94dfbe85dca5a974eff36Prakash Surya "%llxL B=%llu",
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman "%llxL/%llxP F=%llu B=%llu/%llu",
7802d7bf98dec568dadf72286893b1fe5abd8602Matthew Ahrensprint_indirect(blkptr_t *bp, const zbookmark_phys_t *zb,
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens ASSERT3U(BP_GET_LEVEL(bp), ==, zb->zb_level);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) printf("%16llx ", (u_longlong_t)blkid2offset(dnp, bp, zb));
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens (void) printf("L%llx", (u_longlong_t)zb->zb_level);
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman snprintf_blkptr_compact(blkbuf, sizeof (blkbuf), bp);
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrensvisit_indirect(spa_t *spa, const dnode_phys_t *dnp,
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens int epb = BP_GET_LSIZE(bp) >> SPA_BLKPTRSHIFT;
1b912ec7100c10e7243bf0879af0fe580e08c73dGeorge Wilson err = arc_read(NULL, spa, bp, arc_getbuf_func, &buf,
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens ZIO_PRIORITY_ASYNC_READ, ZIO_FLAG_CANFAIL, &flags, zb);
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens /* recursively visit blocks below this */
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens SET_BOOKMARK(&czb, zb->zb_objset, zb->zb_object,
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*ARGSUSED*/
503ad85c168c7992ccc310af845a581cff3c72b5Matthew Ahrens SET_BOOKMARK(&czb, dmu_objset_id(dn->dn_objset),
503ad85c168c7992ccc310af845a581cff3c72b5Matthew Ahrens (void) visit_indirect(dmu_objset_spa(dn->dn_objset), dnp,
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*ARGSUSED*/
fa9e4066f08beec538e775443c5be79dd423fcabahrensdump_dsl_dir(objset_t *os, uint64_t object, void *data, size_t size)
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) printf("\t\tcreation_time = %s", ctime(&crtime));
74e7dc986c89efca1f2e4451c7a572e05e4a6e4fMatthew Ahrens (void) printf("\t\tused_bytes = %s\n", nice);
74e7dc986c89efca1f2e4451c7a572e05e4a6e4fMatthew Ahrens (void) printf("\t\tcompressed_bytes = %s\n", nice);
74e7dc986c89efca1f2e4451c7a572e05e4a6e4fMatthew Ahrens (void) printf("\t\tuncompressed_bytes = %s\n", nice);
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling zdb_nicenum(dd->dd_used_breakdown[DD_USED_ ## which], nice); \
74e7dc986c89efca1f2e4451c7a572e05e4a6e4fMatthew Ahrens (void) printf("\t\tused_breakdown[" #which "] = %s\n", nice)
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*ARGSUSED*/
fa9e4066f08beec538e775443c5be79dd423fcabahrensdump_dsl_dataset(objset_t *os, uint64_t object, void *data, size_t size)
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling char used[32], compressed[32], uncompressed[32], unique[32];
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden zdb_nicenum(ds->ds_referenced_bytes, used);
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling zdb_nicenum(ds->ds_uncompressed_bytes, uncompressed);
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman snprintf_blkptr(blkbuf, sizeof (blkbuf), &ds->ds_bp);
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) printf("\t\tcreation_time = %s", ctime(&crtime));
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) printf("\t\tcompressed_bytes = %s\n", compressed);
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) printf("\t\tuncompressed_bytes = %s\n", uncompressed);
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Sidendump_bptree_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Sidendump_bptree(objset_t *os, uint64_t obj, char *name)
b420f3adeb349714478d1a7813d2c0e069d41555Richard Lowe VERIFY3U(0, ==, dmu_bonus_hold(os, obj, FTAG, &db));
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden (void) printf("\n %s: %llu datasets, %s\n",
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden name, (unsigned long long)(bt->bt_end - bt->bt_begin), bytes);
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden (void) bptree_iterate(os, obj, B_FALSE, dump_bptree_cb, NULL, NULL);
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrens/* ARGSUSED */
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrensdump_bpobj_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman snprintf_blkptr_compact(blkbuf, sizeof (blkbuf), bp);
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrensdump_full_bpobj(bpobj_t *bpo, char *name, int indent)
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrens zdb_nicenum(bpo->bpo_phys->bpo_bytes, bytes);
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens if (bpo->bpo_havesubobj && bpo->bpo_phys->bpo_subobjs != 0) {
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrens zdb_nicenum(bpo->bpo_phys->bpo_uncomp, uncomp);
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens (void) printf(" %*s: object %llu, %llu local blkptrs, "
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrens "%llu subobjs in object %llu, %s (%s/%s comp)\n",
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens (u_longlong_t)bpo->bpo_phys->bpo_num_blkptrs,
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrens (u_longlong_t)bpo->bpo_phys->bpo_num_subobjs,
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens for (uint64_t i = 0; i < bpo->bpo_phys->bpo_num_subobjs; i++) {
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens i * sizeof (subobj), sizeof (subobj), &subobj, 0));
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens error = bpobj_open(&subbpo, bpo->bpo_os, subobj);
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens (void) printf("ERROR %u while trying to open "
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens "subobj id %llu\n",
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrens dump_full_bpobj(&subbpo, "subobj", indent + 1);
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens (void) printf(" %*s: object %llu, %llu blkptrs, %s\n",
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens (u_longlong_t)bpo->bpo_phys->bpo_num_blkptrs,
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens (void) bpobj_iterate_nofree(bpo, dump_bpobj_cb, NULL, NULL);
732885fca09e11183dd0ea69aaaab5588fb7dbffMatthew Ahrens dump_full_bpobj(&dl->dl_bpobj, "old-format deadlist", 0);
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrens (void) printf("\n Deadlist: %s (%s/%s comp)\n",
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens /* force the tree to be loaded */
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens dsl_deadlist_space_range(dl, 0, UINT64_MAX, &unused, &unused, &unused);
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens (void) snprintf(buf, sizeof (buf), "mintxg %llu -> ",
e0d35c4478bf9fd4080951b5b9d1f9a38948ba69marks * print uid or gid information.
e0d35c4478bf9fd4080951b5b9d1f9a38948ba69marks * For normal POSIX id just the id is printed in decimal format.
e0d35c4478bf9fd4080951b5b9d1f9a38948ba69marks * For CIFS files with FUID the fuid is printed in hex followed by
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens * the domain-rid string.
e0d35c4478bf9fd4080951b5b9d1f9a38948ba69marks domain = zfs_fuid_idx_domain(&idx_tree, FUID_INDEX(id));
e0d35c4478bf9fd4080951b5b9d1f9a38948ba69marks (void) printf("\t%s %llu\n", id_type, (u_longlong_t)id);
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaumdump_uidgid(objset_t *os, uint64_t uid, uint64_t gid)
e0d35c4478bf9fd4080951b5b9d1f9a38948ba69marks /* Load domain table, if not already loaded */
e0d35c4478bf9fd4080951b5b9d1f9a38948ba69marks /* first find the fuid object. It lives in the master node */
e0d35c4478bf9fd4080951b5b9d1f9a38948ba69marks VERIFY(zap_lookup(os, MASTER_NODE_OBJ, ZFS_FUID_TABLES,
89459e17032b6bb1d59eebd2b7c0d06859d4657cMark Shellenbaum zfs_fuid_avl_tree_create(&idx_tree, &domain_tree);
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*ARGSUSED*/
fa9e4066f08beec538e775443c5be79dd423fcabahrensdump_znode(objset_t *os, uint64_t object, void *data, size_t size)
fa9e4066f08beec538e775443c5be79dd423fcabahrens char path[MAXPATHLEN * 2]; /* allow for xattr and failure prefix */
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum uint64_t uid, gid, mode, fsize, parent, links;
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum uint64_t acctm[2], modtm[2], chgtm[2], crtm[2];
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum time_t z_crtime, z_atime, z_mtime, z_ctime;
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum VERIFY(zap_lookup(os, MASTER_NODE_OBJ, ZPL_VERSION_STR,
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum VERIFY(zap_lookup(os, MASTER_NODE_OBJ, ZFS_SA_ATTRS,
1d8ccc7bfd8ab0f27a23c5253d95c22ceb9c27f4Mark Shellenbaum if ((error = sa_setup(os, sa_attrs, zfs_attr_table,
1d8ccc7bfd8ab0f27a23c5253d95c22ceb9c27f4Mark Shellenbaum (void) printf("sa_setup failed errno %d, can't "
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum if (sa_handle_get(os, object, NULL, SA_HDL_PRIVATE, &hdl)) {
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum (void) printf("Failed to get handle for SA znode\n");
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_UID], NULL, &uid, 8);
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_GID], NULL, &gid, 8);
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_LINKS], NULL,
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_GEN], NULL, &gen, 8);
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_MODE], NULL,
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_PARENT],
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_SIZE], NULL,
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_ATIME], NULL,
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_MTIME], NULL,
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_CRTIME], NULL,
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_CTIME], NULL,
8f2529de2d60d4fff8eb4d86f71b51584342934eMark Shellenbaum SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_FLAGS], NULL,
55434c770c89aa1b84474f2559a106803511aba0ek error = zfs_obj_to_path(os, object, path, sizeof (path));
55434c770c89aa1b84474f2559a106803511aba0ek if (error != 0) {
55434c770c89aa1b84474f2559a106803511aba0ek (void) snprintf(path, sizeof (path), "\?\?\?<object#%llu>",
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum (void) printf("\tgen %llu\n", (u_longlong_t)gen);
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum (void) printf("\tmode %llo\n", (u_longlong_t)mode);
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum (void) printf("\tsize %llu\n", (u_longlong_t)fsize);
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum (void) printf("\tparent %llu\n", (u_longlong_t)parent);
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum (void) printf("\tlinks %llu\n", (u_longlong_t)links);
8f2529de2d60d4fff8eb4d86f71b51584342934eMark Shellenbaum (void) printf("\tpflags %llx\n", (u_longlong_t)pflags);
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum if (sa_lookup(hdl, sa_attr_table[ZPL_XATTR], &xattr,
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum sizeof (uint64_t)) == 0)
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum (void) printf("\txattr %llu\n", (u_longlong_t)xattr);
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum if (sa_lookup(hdl, sa_attr_table[ZPL_RDEV], &rdev,
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum sizeof (uint64_t)) == 0)
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum (void) printf("\trdev 0x%016llx\n", (u_longlong_t)rdev);
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*ARGSUSED*/
fa9e4066f08beec538e775443c5be79dd423fcabahrensdump_acl(objset_t *os, uint64_t object, void *data, size_t size)
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*ARGSUSED*/
fa9e4066f08beec538e775443c5be79dd423fcabahrensdump_dmu_objset(objset_t *os, uint64_t object, void *data, size_t size)
6de8f417ed556c30c2c5d24961e26ca586e636a1Victor Latushkinstatic object_viewer_t *object_viewer[DMU_OT_NUMTYPES + 1] = {
4445fffbbb1ea25fd0e9ea68b9380dd7a6709025Matthew Ahrens dump_history_offsets, /* SPA history offsets */
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum dump_sa_attrs, /* SA attribute registration */
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum dump_sa_layouts, /* SA attribute layouts */
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum dump_unknown, /* Unknown type, must be last */
fa9e4066f08beec538e775443c5be79dd423fcabahrensdump_object(objset_t *os, uint64_t object, int verbosity, int *print_header)
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling char iblk[32], dblk[32], lsize[32], asize[32], fill[32];
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) printf("\n%10s %3s %5s %5s %5s %5s %6s %s\n",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick "Object", "lvl", "iblk", "dblk", "dsize", "lsize",
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (object == 0) {
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling zdb_nicenum(doi.doi_physical_blocks_512 << 9, asize);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) sprintf(fill, "%6.2f", 100.0 * doi.doi_fill_count *
bbfd46c40e81c7d954cec28db66453ec5ab44613Jeff Bonwick doi.doi_data_block_size / (object == 0 ? DNODES_PER_BLOCK : 1) /
e7437265dc2a4920c197ed4337665539d358b22cahrens if (doi.doi_checksum != ZIO_CHECKSUM_INHERIT || verbosity >= 6) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) snprintf(aux + strlen(aux), sizeof (aux), " (K=%s)",
e7437265dc2a4920c197ed4337665539d358b22cahrens if (doi.doi_compress != ZIO_COMPRESS_INHERIT || verbosity >= 6) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) snprintf(aux + strlen(aux), sizeof (aux), " (Z=%s)",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) printf("%10lld %3u %5s %5s %5s %5s %6s %s%s\n",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (u_longlong_t)object, doi.doi_indirection, iblk, dblk,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick asize, lsize, fill, ZDB_OT_NAME(doi.doi_type), aux);
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (doi.doi_bonus_type != DMU_OT_NONE && verbosity > 3) {
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) printf("%10s %3s %5s %5s %5s %5s %6s %s\n",
148434217c040ea38dc844384f6ba68d9b325906Matthew Ahrens (dn->dn_phys->dn_flags & DNODE_FLAG_USED_BYTES) ?
148434217c040ea38dc844384f6ba68d9b325906Matthew Ahrens (dn->dn_phys->dn_flags & DNODE_FLAG_USERUSED_ACCOUNTED) ?
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum (dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR) ?
6de8f417ed556c30c2c5d24961e26ca586e636a1Victor Latushkin object_viewer[ZDB_OT_TYPE(doi.doi_bonus_type)](os, object,
6de8f417ed556c30c2c5d24961e26ca586e636a1Victor Latushkin object_viewer[ZDB_OT_TYPE(doi.doi_type)](os, object, NULL, 0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Report the list of segments that comprise the object.
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens dsl_pool_config_enter(dmu_objset_pool(os), FTAG);
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens dsl_pool_config_exit(dmu_objset_pool(os), FTAG);
c1379625401dfbe1c39b79136dd384a571d47fdeJustin T. Gibbs refdbytes = dsl_dir_phys(os->os_spa->spa_dsl_pool->dp_mos_dir)->
a2eea2e101e6a163a537dcc6d4e3c4da2a0ea5b2ahrens dmu_objset_space(os, &refdbytes, &scratch, &usedobjs, &scratch);
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens ASSERT3U(usedobjs, ==, BP_GET_FILL(os->os_rootbp));
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman (void) snprintf(blkbuf, sizeof (blkbuf), ", rootbp ");
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman (void) snprintf_blkptr(blkbuf + strlen(blkbuf),
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman sizeof (blkbuf) - strlen(blkbuf), os->os_rootbp);
a2eea2e101e6a163a537dcc6d4e3c4da2a0ea5b2ahrens (void) printf("Dataset %s [%s], ID %llu, cr_txg %llu, "
fa9e4066f08beec538e775443c5be79dd423fcabahrens "%s, %llu objects%s\n",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick for (i = 0; i < zopt_objects; i++)
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrens dump_deadlist(&dmu_objset_ds(os)->ds_deadlist);
148434217c040ea38dc844384f6ba68d9b325906Matthew Ahrens dump_object(os, DMU_USERUSED_OBJECT, verbosity, &print_header);
148434217c040ea38dc844384f6ba68d9b325906Matthew Ahrens dump_object(os, DMU_GROUPUSED_OBJECT, verbosity, &print_header);
6754306ec9a89fd28806908d10c76141e8fbba3fahrens while ((error = dmu_object_next(os, &object, B_FALSE, 0)) == 0) {
ccba08015a17f88186762dd6d9f91195adb387e8Rich Morris (void) fprintf(stderr, "dmu_object_next() = %d\n", error);
53b9a4a991f4dadb1eab425560f62ba14ae5c5aeVictor Latushkindump_uberblock(uberblock_t *ub, const char *header, const char *footer)
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) printf("\tmagic = %016llx\n", (u_longlong_t)ub->ub_magic);
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) printf("\tversion = %llu\n", (u_longlong_t)ub->ub_version);
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) printf("\ttxg = %llu\n", (u_longlong_t)ub->ub_txg);
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) printf("\tguid_sum = %llu\n", (u_longlong_t)ub->ub_guid_sum);
fa9e4066f08beec538e775443c5be79dd423fcabahrens (u_longlong_t)ub->ub_timestamp, asctime(localtime(×tamp)));
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman snprintf_blkptr(blkbuf, sizeof (blkbuf), &ub->ub_rootbp);
07428bdfb7bca7c9e74959692785555ea5e27ce2Victor Latushkin error = dmu_bonus_hold(spa->spa_meta_objset,
07428bdfb7bca7c9e74959692785555ea5e27ce2Victor Latushkin spa->spa_config_object, (void *)&nvsize, 1);
07428bdfb7bca7c9e74959692785555ea5e27ce2Victor Latushkin (void) fprintf(stderr, "dmu_bonus_hold(%llu) failed, errno %d",
07428bdfb7bca7c9e74959692785555ea5e27ce2Victor Latushkin (u_longlong_t)spa->spa_config_object, error);
c5904d138f3bdf0762dbf452a43d5a5c387ea6a8eschrock (void) printf("failed to stat '%s': %s\n", cachefile,
c5904d138f3bdf0762dbf452a43d5a5c387ea6a8eschrock (void) fprintf(stderr, "failed to allocate %llu bytes\n",
c5904d138f3bdf0762dbf452a43d5a5c387ea6a8eschrock if (read(fd, buf, statbuf.st_size) != statbuf.st_size) {
c5904d138f3bdf0762dbf452a43d5a5c387ea6a8eschrock (void) fprintf(stderr, "failed to read %llu bytes\n",
c5904d138f3bdf0762dbf452a43d5a5c387ea6a8eschrock if (nvlist_unpack(buf, statbuf.st_size, &config, 0) != 0) {
c5904d138f3bdf0762dbf452a43d5a5c387ea6a8eschrock (void) fprintf(stderr, "failed to unpack nvlist\n");
53b9a4a991f4dadb1eab425560f62ba14ae5c5aeVictor Latushkindump_label_uberblocks(vdev_label_t *lbl, uint64_t ashift)
53b9a4a991f4dadb1eab425560f62ba14ae5c5aeVictor Latushkin for (int i = 0; i < VDEV_UBERBLOCK_COUNT(vdp); i++) {
53b9a4a991f4dadb1eab425560f62ba14ae5c5aeVictor Latushkin uint64_t uoff = VDEV_UBERBLOCK_OFFSET(vdp, i);
53b9a4a991f4dadb1eab425560f62ba14ae5c5aeVictor Latushkin uberblock_t *ub = (void *)((char *)lbl + uoff);
53b9a4a991f4dadb1eab425560f62ba14ae5c5aeVictor Latushkin (void) snprintf(header, ZDB_MAX_UB_HEADER_SIZE,
53b9a4a991f4dadb1eab425560f62ba14ae5c5aeVictor Latushkin "Uberblock[%d]\n", i);
c6065d0f56bc07a4d96dcfa56f84104dbfb0343fGeorge Wilson char *path, *buf = label.vl_vdev_phys.vp_nvlist;
fa9e4066f08beec538e775443c5be79dd423fcabahrens size_t buflen = sizeof (label.vl_vdev_phys.vp_nvlist);
6401734d545a04c18f68b448202f9d9a77216bb9Will Andrews if (strncmp(dev, ZFS_DISK_ROOTD, strlen(ZFS_DISK_ROOTD)) == 0) {
6401734d545a04c18f68b448202f9d9a77216bb9Will Andrews (void) snprintf(path, len, "%s%s", ZFS_RDISK_ROOTD,
c6065d0f56bc07a4d96dcfa56f84104dbfb0343fGeorge Wilson (void) printf("cannot open '%s': %s\n", path, strerror(errno));
c6065d0f56bc07a4d96dcfa56f84104dbfb0343fGeorge Wilson (void) printf("failed to stat '%s': %s\n", path,
c6065d0f56bc07a4d96dcfa56f84104dbfb0343fGeorge Wilson (void) printf("cannot use '%s': character device required\n",
fa9e4066f08beec538e775443c5be79dd423fcabahrens psize = P2ALIGN(psize, (uint64_t)sizeof (vdev_label_t));
53b9a4a991f4dadb1eab425560f62ba14ae5c5aeVictor Latushkin for (int l = 0; l < VDEV_LABELS; l++) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) printf("--------------------------------------------\n");
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) printf("--------------------------------------------\n");
53b9a4a991f4dadb1eab425560f62ba14ae5c5aeVictor Latushkin ZPOOL_CONFIG_VDEV_TREE, &vdev_tree) != 0) ||
ca0cc3918a1789fa839194af2a9245f801a06b1aMatthew Ahrensstatic uint64_t dataset_feature_count[SPA_FEATURES];
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*ARGSUSED*/
503ad85c168c7992ccc310af845a581cff3c72b5Matthew Ahrens error = dmu_objset_own(dsname, DMU_OST_ANY, B_TRUE, FTAG, &os);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) printf("Could not open %s, error %d\n", dsname, error);
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens return (0);
ca0cc3918a1789fa839194af2a9245f801a06b1aMatthew Ahrens for (spa_feature_t f = 0; f < SPA_FEATURES; f++) {
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens return (0);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * Block statistics.
b515258426fed6c7311fd3f1dea697cfbd4085c6Matthew Ahrens#define PSIZE_HISTO_SIZE (SPA_OLD_MAXBLOCKSIZE / SPA_MINBLOCKSIZE + 2)
490d05b9daa0e60fbb3aac647c556408e88228bdMatthew Ahrens uint64_t zb_psize_histogram[PSIZE_HISTO_SIZE];
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * Extended object types to report deferred frees and dedup auto-ditto blocks.
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick "deferred free",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick "dedup ditto",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick zdb_blkstats_t zcb_type[ZB_TOTAL + 1][ZDB_OT_TOTAL + 1];
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens uint64_t zcb_embedded_blocks[NUM_BP_EMBEDDED_TYPES];
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens uint64_t zcb_embedded_histogram[NUM_BP_EMBEDDED_TYPES]
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrenszdb_count_block(zdb_cb_t *zcb, zilog_t *zilog, const blkptr_t *bp,
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick for (int i = 0; i < 4; i++) {
b515258426fed6c7311fd3f1dea697cfbd4085c6Matthew Ahrens * The histogram is only big enough to record blocks up to
b515258426fed6c7311fd3f1dea697cfbd4085c6Matthew Ahrens * SPA_OLD_MAXBLOCKSIZE; larger blocks go into the last,
b515258426fed6c7311fd3f1dea697cfbd4085c6Matthew Ahrens * "other", bucket.
b515258426fed6c7311fd3f1dea697cfbd4085c6Matthew Ahrens int idx = BP_GET_PSIZE(bp) >> SPA_MINBLOCKSHIFT;
b515258426fed6c7311fd3f1dea697cfbd4085c6Matthew Ahrens idx = MIN(idx, SPA_OLD_MAXBLOCKSIZE / SPA_MINBLOCKSIZE + 1);
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens zcb->zcb_embedded_blocks[BPE_GET_ETYPE(bp)]++;
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens zcb->zcb_embedded_histogram[BPE_GET_ETYPE(bp)]
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrens VERIFY3U(zio_wait(zio_claim(NULL, zcb->zcb_spa,
31d7e8fa33fae995f558673adb22641b5aa8b6e1George Wilson zio_data_buf_free(zio->io_data, zio->io_size);
31d7e8fa33fae995f558673adb22641b5aa8b6e1George Wilson if (ioerr && !(zio->io_flags & ZIO_FLAG_SPECULATIVE)) {
31d7e8fa33fae995f558673adb22641b5aa8b6e1George Wilson "Got error %d reading "
31d7e8fa33fae995f558673adb22641b5aa8b6e1George Wilson "<%llu, %llu, %lld, %llx> %s -- skipping\n",
1b912ec7100c10e7243bf0879af0fe580e08c73dGeorge Wilsonzdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
7802d7bf98dec568dadf72286893b1fe5abd8602Matthew Ahrens const zbookmark_phys_t *zb, const dnode_phys_t *dnp, void *arg)
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman "level %lld offset 0x%llx %s\n",
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden (type & DMU_OT_NEWTYPE) ? ZDB_OT_OTHER : type);
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden is_metadata = (BP_GET_LEVEL(bp) != 0 || DMU_OT_IS_METADATA(type));
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens (dump_opt['c'] > 1 || (dump_opt['c'] && is_metadata))) {
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick int flags = ZIO_FLAG_CANFAIL | ZIO_FLAG_SCRUB | ZIO_FLAG_RAW;
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick /* If it's an intent log block, failure is expected. */
31d7e8fa33fae995f558673adb22641b5aa8b6e1George Wilson while (spa->spa_scrub_inflight > max_inflight)
31d7e8fa33fae995f558673adb22641b5aa8b6e1George Wilson cv_wait(&spa->spa_scrub_io_cv, &spa->spa_scrub_lock);
31d7e8fa33fae995f558673adb22641b5aa8b6e1George Wilson zio_nowait(zio_read(NULL, spa, bp, data, size,
31d7e8fa33fae995f558673adb22641b5aa8b6e1George Wilson zdb_blkptr_done, zcb, ZIO_PRIORITY_ASYNC_READ, flags, zb));
f7950bf1145637c6dc57742a8bb95631fd5c846fMatthew Ahrens /* only call gethrtime() every 100 blocks */
f7950bf1145637c6dc57742a8bb95631fd5c846fMatthew Ahrens if (dump_opt['b'] < 5 && gethrtime() > zcb->zcb_lastprint + NANOSEC) {
490d05b9daa0e60fbb3aac647c556408e88228bdMatthew Ahrens uint64_t bytes = zcb->zcb_type[ZB_TOTAL][ZDB_OT_TOTAL].zb_asize;
490d05b9daa0e60fbb3aac647c556408e88228bdMatthew Ahrens 1 + bytes / (1 + ((now - zcb->zcb_start) / 1000 / 1000));
490d05b9daa0e60fbb3aac647c556408e88228bdMatthew Ahrens (zcb->zcb_totalasize - bytes) / 1024 / kb_per_sec;
490d05b9daa0e60fbb3aac647c556408e88228bdMatthew Ahrens "\r%5s completed (%4dMB/s) "
490d05b9daa0e60fbb3aac647c556408e88228bdMatthew Ahrens "estimated time remaining: %uhr %02umin %02usec ",
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilsonzdb_leak(void *arg, uint64_t start, uint64_t size)
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) printf("leaked space: vdev %llu, offset 0x%llx, size %llu\n",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (u_longlong_t)vd->vdev_id, (u_longlong_t)start, (u_longlong_t)size);
bbfd46c40e81c7d954cec28db66453ec5ab44613Jeff Bonwick while ((error = ddt_walk(spa, &ddb, &dde)) == 0) {
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick for (int p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrens zdb_count_block(zcb, NULL, &blk, ZDB_OT_DITTO);
8363e80ae72609660f6090766ca8c2c18aa53f0cGeorge Wilson * We are going to be changing the meaning of the metaslab's
8363e80ae72609660f6090766ca8c2c18aa53f0cGeorge Wilson * ms_tree. Ensure that the allocator doesn't try to
8363e80ae72609660f6090766ca8c2c18aa53f0cGeorge Wilson * use the tree.
8363e80ae72609660f6090766ca8c2c18aa53f0cGeorge Wilson spa->spa_normal_class->mc_ops = &zdb_metaslab_ops;
8363e80ae72609660f6090766ca8c2c18aa53f0cGeorge Wilson spa->spa_log_class->mc_ops = &zdb_metaslab_ops;
06be98028b8a84e7f327188613dd09a708294d1aMatthew Ahrens for (uint64_t c = 0; c < rvd->vdev_children; c++) {
06be98028b8a84e7f327188613dd09a708294d1aMatthew Ahrens for (uint64_t m = 0; m < vd->vdev_ms_count; m++) {
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * For leak detection, we overload the metaslab
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * ms_tree to contain allocated segments
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * instead of free segments. As a result,
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * we can't use the normal metaslab_load/unload
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * interfaces.
06be98028b8a84e7f327188613dd09a708294d1aMatthew Ahrens "\rloading space map for "
06be98028b8a84e7f327188613dd09a708294d1aMatthew Ahrens "vdev %llu of %llu, "
06be98028b8a84e7f327188613dd09a708294d1aMatthew Ahrens "metaslab %llu of %llu ...",
f7950bf1145637c6dc57742a8bb95631fd5c846fMatthew Ahrens * We don't want to spend the CPU
f7950bf1145637c6dc57742a8bb95631fd5c846fMatthew Ahrens * manipulating the size-ordered
f7950bf1145637c6dc57742a8bb95631fd5c846fMatthew Ahrens * tree, so clear the range_tree
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER);
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * The ms_tree has been overloaded to
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * contain allocated segments. Now that we
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * finished traversing all blocks, any
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * block that remains in the ms_tree
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * represents an allocated block that we
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * did not claim during the traversal.
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * Claimed blocks would have been removed
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * from the ms_tree.
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson range_tree_vacate(msp->ms_tree, zdb_leak, vd);
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrens/* ARGSUSED */
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrenscount_block_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrens zdb_count_block(zcb, NULL, bp, ZDB_OT_DEFERRED);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick uint64_t norm_alloc, norm_space, total_alloc, total_found;
cd088ea442a404aa7cfc0ddc6ed8e92f73416102Victor Latushkin int flags = TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA | TRAVERSE_HARD;
490d05b9daa0e60fbb3aac647c556408e88228bdMatthew Ahrens (void) printf("\nTraversing all blocks %s%s%s%s%s...\n\n",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (dump_opt['c'] || !dump_opt['L']) ? "to verify " : "",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (dump_opt['c'] && !dump_opt['L']) ? "and verify " : "",
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick * Load all space maps as SM_ALLOC maps, then traverse the pool
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick * claiming each block we discover. If the pool is perfectly
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick * consistent, the space maps will be empty when we're done.
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick * Anything left over is a leak; any block we can't claim (because
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick * it's not part of any space map) is a double allocation,
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick * reference to a freed block, or an unclaimed log block.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If there's a deferred-free bplist, process that first.
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrens (void) bpobj_iterate_nofree(&spa->spa_deferred_bpobj,
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens if (spa_version(spa) >= SPA_VERSION_DEADLISTS) {
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens (void) bpobj_iterate_nofree(&spa->spa_dsl_pool->dp_free_bpobj,
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens if (spa_feature_is_active(spa, SPA_FEATURE_ASYNC_DESTROY)) {
b420f3adeb349714478d1a7813d2c0e069d41555Richard Lowe VERIFY3U(0, ==, bptree_iterate(spa->spa_meta_objset,
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden spa->spa_dsl_pool->dp_bptree_obj, B_FALSE, count_block_cb,
490d05b9daa0e60fbb3aac647c556408e88228bdMatthew Ahrens zcb.zcb_totalasize = metaslab_class_get_alloc(spa_normal_class(spa));
490d05b9daa0e60fbb3aac647c556408e88228bdMatthew Ahrens zcb.zcb_start = zcb.zcb_lastprint = gethrtime();
bbfd46c40e81c7d954cec28db66453ec5ab44613Jeff Bonwick zcb.zcb_haderrors |= traverse_pool(spa, 0, flags, zdb_blkptr_cb, &zcb);
31d7e8fa33fae995f558673adb22641b5aa8b6e1George Wilson * If we've traversed the data blocks then we need to wait for those
31d7e8fa33fae995f558673adb22641b5aa8b6e1George Wilson * I/Os to complete. We leverage "The Godfather" zio to wait on
31d7e8fa33fae995f558673adb22641b5aa8b6e1George Wilson * all async I/Os to complete.
6f834bc197c703a6568554c889157fb345bac079Matthew Ahrens for (int i = 0; i < max_ncpus; i++) {
6f834bc197c703a6568554c889157fb345bac079Matthew Ahrens spa->spa_async_zio_root[i] = zio_root(spa, NULL, NULL,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick for (int e = 0; e < 256; e++) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Report any leaked segments.
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick norm_alloc = metaslab_class_get_alloc(spa_normal_class(spa));
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick norm_space = metaslab_class_get_space(spa_normal_class(spa));
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick total_alloc = norm_alloc + metaslab_class_get_alloc(spa_log_class(spa));
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick total_found = tzb->zb_asize - zcb.zcb_dedup_asize;
82a0a985b0e8df9eae061303b421d2df27c728f0Victor Latushkin (void) printf("\n\tNo leaks (block sum matches space"
82a0a985b0e8df9eae061303b421d2df27c728f0Victor Latushkin " maps exactly)\n");
fa9e4066f08beec538e775443c5be79dd423fcabahrens (void) printf("block traversal size %llu != alloc %llu "
82a0a985b0e8df9eae061303b421d2df27c728f0Victor Latushkin "(%s %lld)\n",
82a0a985b0e8df9eae061303b421d2df27c728f0Victor Latushkin (dump_opt['L']) ? "unreachable" : "leaked",
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (2);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) printf("\tbp logical: %10llu avg: %6llu\n",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick " %6llu compression: %6.2f\n",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick " %6llu compression: %6.2f\n",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick " %6llu deduplication: %6.2f\n",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (double)zcb.zcb_dedup_asize / tzb->zb_asize + 1.0);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) printf("\tSPA allocated: %10llu used: %5.2f%%\n",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (u_longlong_t)norm_alloc, 100.0 * norm_alloc / norm_space);
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens for (bp_embedded_type_t i = 0; i < NUM_BP_EMBEDDED_TYPES; i++) {
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens (void) printf("\tadditional, non-pointer bps of type %u: "
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens i, (u_longlong_t)zcb.zcb_embedded_blocks[i]);
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens (void) printf("\t number of (compressed) bytes: "
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens "number of bps\n");
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens dump_histogram(zcb.zcb_embedded_histogram[i],
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens sizeof (zcb.zcb_embedded_histogram[i][0]), 0);
d5ee8a1311accef11ec2057f70da38d1dd687088Matthew Ahrens (void) printf("\tDittoed blocks on same vdev: %llu\n",
fa9e4066f08beec538e775443c5be79dd423fcabahrens "\t avg\t comp\t%%Total\tType\n");
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick for (t = 0; t <= ZDB_OT_TOTAL; t++) {
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick typename = zdb_ot_extname[t - DMU_OT_NUMTYPES];
fa9e4066f08beec538e775443c5be79dd423fcabahrens "\t%5s\t%5s\t%6s\t%s\n",
fa9e4066f08beec538e775443c5be79dd423fcabahrens "\t%5.2f\t%6.2f\t",
d5ee8a1311accef11ec2057f70da38d1dd687088Matthew Ahrens if (dump_opt['b'] >= 3 && zb->zb_gangs > 0) {
490d05b9daa0e60fbb3aac647c556408e88228bdMatthew Ahrens "(in 512-byte sectors): "
490d05b9daa0e60fbb3aac647c556408e88228bdMatthew Ahrens "number of blocks\n");
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (2);
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (3);
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick/* ARGSUSED */
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickzdb_ddt_add_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
7802d7bf98dec568dadf72286893b1fe5abd8602Matthew Ahrens const zbookmark_phys_t *zb, const dnode_phys_t *dnp, void *arg)
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagnelie if (bp == NULL || BP_IS_HOLE(bp) || BP_IS_EMBEDDED(bp))
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick if (dump_opt['S'] > 1 && zb->zb_level == ZB_ROOT_LEVEL) {
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) printf("traversing objset %llu, %llu objects, "
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick "%lu blocks so far\n",
bbfd46c40e81c7d954cec28db66453ec5ab44613Jeff Bonwick if (BP_IS_HOLE(bp) || BP_GET_CHECKSUM(bp) == ZIO_CHECKSUM_OFF ||
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden BP_GET_LEVEL(bp) > 0 || DMU_OT_IS_METADATA(BP_GET_TYPE(bp)))
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick zdde = umem_zalloc(sizeof (*zdde), UMEM_NOFAIL);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick zdde->zdde_ref_dsize += bp_get_dsize_sync(spa, bp);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick sizeof (zdb_ddt_entry_t), offsetof(zdb_ddt_entry_t, zdde_node));
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER);
bbfd46c40e81c7d954cec28db66453ec5ab44613Jeff Bonwick (void) traverse_pool(spa, 0, TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick while ((zdde = avl_destroy_nodes(&t, &cookie)) != NULL) {
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick dds.dds_blocks = zdde->zdde_ref_blocks / refcnt;
bf16b11e8deb633dd6c4296d46e92399d1582df4Matthew Ahrens ddt_stat_add(&ddh_total.ddh_stat[highbit64(refcnt) - 1],
07428bdfb7bca7c9e74959692785555ea5e27ce2Victor Latushkin (void) printf("\nCached configuration:\n");
53b9a4a991f4dadb1eab425560f62ba14ae5c5aeVictor Latushkin dump_uberblock(&spa->spa_uberblock, "\nUberblock:\n", "\n");
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens "Deferred frees", 0);
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrens if (spa_version(spa) >= SPA_VERSION_DEADLISTS) {
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens "Pool snapshot frees", 0);
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden "Pool dataset frees");
07428bdfb7bca7c9e74959692785555ea5e27ce2Victor Latushkin (void) dmu_objset_find(spa_name(spa), dump_one_dir,
07428bdfb7bca7c9e74959692785555ea5e27ce2Victor Latushkin NULL, DS_FIND_SNAPSHOTS | DS_FIND_CHILDREN);
ca0cc3918a1789fa839194af2a9245f801a06b1aMatthew Ahrens for (spa_feature_t f = 0; f < SPA_FEATURES; f++) {
ca0cc3918a1789fa839194af2a9245f801a06b1aMatthew Ahrens (void) printf("%s feature refcount mismatch: "
ca0cc3918a1789fa839194af2a9245f801a06b1aMatthew Ahrens "%lld datasets != %lld refcount\n",
ca0cc3918a1789fa839194af2a9245f801a06b1aMatthew Ahrens (void) printf("Verified %s feature refcount "
ca0cc3918a1789fa839194af2a9245f801a06b1aMatthew Ahrens "of %llu is correct\n",
b515258426fed6c7311fd3f1dea697cfbd4085c6Matthew Ahrens if (rc == 0 && (dump_opt['b'] || dump_opt['c']))
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm for (i = 0; i < nbps; i++)
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm zdb_dump_indirect((blkptr_t *)buf, SPA_GBH_NBLKPTRS, flags);
44cd46cadd9aab751dae6a4023c1cb5bf316d274billmzdb_dump_block_raw(void *buf, uint64_t size, int flags)
44cd46cadd9aab751dae6a4023c1cb5bf316d274billmzdb_dump_block(char *label, void *buf, uint64_t size, int flags)
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm (void) printf("\n%s\n%6s %s 0123456789abcdef\n", label, "", hdr);
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm (u_longlong_t)(do_bswap ? BSWAP_64(d[i + 1]) : d[i + 1]));
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm c = (char *)&d[i];
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * There are two acceptable formats:
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * leaf_name - For example: c1t0d0 or /tmp/ztest.0a
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * child[.child]* - For example: 0.1.1
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * The second form can be used to specify arbitrary vdevs anywhere
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * in the heirarchy. For example, in a pool with a mirror of
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * RAID-Zs, you can specify either RAID-Z vdev with 0.0 or 0.1 .
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm char *s, *p, *q;
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm /* First, assume the x.x.x.x format */
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm if (*s == '\0')
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm if (strcmp(q, "s0") == 0 && strncmp(p, path, q - p) == 0)
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * Read a block from a pool and print it out. The syntax of the
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * block descriptor is:
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * pool:vdev_specifier:offset:size[:flags]
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * pool - The name of the pool you wish to read from
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * vdev_specifier - Which vdev (see comment for zdb_vdev_lookup)
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * offset - offset, in hex, in bytes
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * size - Amount of data to read, in hex, in bytes
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * flags - A string of characters specifying options
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * b: Decode a blkptr at given offset within block
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * *c: Calculate and display checksums
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * d: Decompress data before dumping
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * e: Byteswap data before dumping
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * g: Display data as a gang block header
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * i: Display as an indirect block
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * p: Do I/O to physical offset
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * r: Dump raw data to stdout
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * * = not yet implemented
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick uint64_t offset = 0, size = 0, psize = 0, lsize = 0, blkptr_offset = 0;
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm s = "size must not be zero";
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm s = "size must be a multiple of sector size";
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm s = "offset must be a multiple of sector size";
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm (void) printf("Invalid block specifier: %s - %s\n", thing, s);
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm for (s = strtok(flagstr, ":"); s; s = strtok(NULL, ":")) {
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm for (i = 0; flagstr[i]; i++) {
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm if (bit == 0) {
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm /* If it's not something with an argument, keep going */
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) fprintf(stderr, "Found vdev type: %s\n",
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick pbuf = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick lbuf = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick DVA_SET_GANG(&dva[0], !!(flags & ZDB_FLAG_GBH));
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick DVA_SET_ASIZE(&dva[0], vdev_psize_to_asize(vd, psize));
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick spa_config_enter(spa, SCL_STATE, FTAG, RW_READER);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * Treat this as a normal block read.
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick zio_nowait(zio_read(zio, spa, bp, pbuf, psize, NULL, NULL,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * Treat this as a vdev child I/O.
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick zio_nowait(zio_vdev_child_io(zio, bp, vd, offset, pbuf, psize,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick ZIO_FLAG_DONT_PROPAGATE | ZIO_FLAG_DONT_RETRY |
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm (void) printf("Read of %s failed, error: %d\n", thing, error);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * We don't know how the data was compressed, so just try
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * every decompress function at every inflated blocksize.
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick void *pbuf2 = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick void *lbuf2 = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick VERIFY(random_get_pseudo_bytes((uint8_t *)pbuf + psize,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick VERIFY(random_get_pseudo_bytes((uint8_t *)pbuf2 + psize,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick for (c = 0; c < ZIO_COMPRESS_FUNCTIONS; c++) {
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick (void) printf("Decompress of %s failed\n", thing);
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm zdb_dump_indirect((blkptr_t *)buf, size / sizeof (blkptr_t),
de6628f04d37509e311b5f382446b2f84e12b570ck if (guid != 0) {
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin if (nvlist_lookup_uint64(cfg, ZPOOL_CONFIG_POOL_GUID, &v) == 0)
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin return (v == guid);
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin if (nvlist_lookup_string(cfg, ZPOOL_CONFIG_POOL_NAME, &s) == 0)
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkinfind_zpool(char **target, nvlist_t **configp, int dirc, char **dirv)
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin if ((sepp = strpbrk(*target, "/@")) != NULL) {
de6628f04d37509e311b5f382446b2f84e12b570ck while ((elem = nvlist_next_nvpair(pools, elem)) != NULL) {
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin /* print previously found config */
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) fatal("\tMatched %d pools - use pool GUID "
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin "instead of pool name or \n"
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin "\tpool name part of a dataset name to select pool", count);
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin * If pool GUID was specified for pool id, replace it with pool name
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin if (name && (strstr(*target, name) != *target)) {
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin int sz = 1 + strlen(name) + ((sepp) ? strlen(sepp) : 0);
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin (void) snprintf(*target, sz, "%s%s", name, sepp ? sepp : "");
ae24175b2b25e9fb4bfd9ac0648b57e0735b6651Cyril Plisko * If there is an environment variable SPA_CONFIG_PATH it overrides
ae24175b2b25e9fb4bfd9ac0648b57e0735b6651Cyril Plisko * default spa_config_path setting. If -U flag is specified it will
ae24175b2b25e9fb4bfd9ac0648b57e0735b6651Cyril Plisko * override this environment variable settings once again.
ae24175b2b25e9fb4bfd9ac0648b57e0735b6651Cyril Plisko spa_config_path_env = getenv("SPA_CONFIG_PATH");
0e60744c982adecd0a1f146f5637475d07ab1069Pavel Zakharov "bcdhilmMI:suCDRSAFLXx:evp:t:U:PGo:")) != -1) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens switch (c) {
31d7e8fa33fae995f558673adb22641b5aa8b6e1George Wilson "of inflight I/Os must be greater "
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin sizeof (char *), UMEM_NOFAIL);
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin sizeof (char *));
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin nsearch * sizeof (char *));
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin if (!dump_opt['e'] && searchdirs != NULL) {
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens (void) fprintf(stderr, "-p option requires use of -e\n");
06be98028b8a84e7f327188613dd09a708294d1aMatthew Ahrens * ZDB does not typically re-read blocks; therefore limit the ARC
06be98028b8a84e7f327188613dd09a708294d1aMatthew Ahrens * to 256 MB, which can be used entirely for metadata.
06be98028b8a84e7f327188613dd09a708294d1aMatthew Ahrens zfs_arc_max = zfs_arc_meta_limit = 256 * 1024 * 1024;
f7950bf1145637c6dc57742a8bb95631fd5c846fMatthew Ahrens * "zdb -c" uses checksum-verifying scrub i/os which are async reads.
f7950bf1145637c6dc57742a8bb95631fd5c846fMatthew Ahrens * "zdb -b" uses traversal prefetch which uses async reads.
f7950bf1145637c6dc57742a8bb95631fd5c846fMatthew Ahrens * For good performance, let several of them be active at once.
4dd77f9e38ef05b39db128ff7608d926fd3218c6Matthew Ahrens * Disable reference tracking for better performance.
fa9e4066f08beec538e775443c5be79dd423fcabahrens for (c = 0; c < 256; c++) {
feef89cf5f5fee792c1a396bb0e48070935cf65aVictor Latushkin aok = (dump_opt['A'] == 1) || (dump_opt['A'] > 2);
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
c8ee1847e300c992c76cf25d6c165e6ccf64a113Victor Latushkin (dump_opt['X'] ? ZPOOL_EXTREME_REWIND : 0);
c8ee1847e300c992c76cf25d6c165e6ccf64a113Victor Latushkin if (nvlist_alloc(&policy, NV_UNIQUE_NAME_TYPE, 0) != 0 ||
c8ee1847e300c992c76cf25d6c165e6ccf64a113Victor Latushkin nvlist_add_uint64(policy, ZPOOL_REWIND_REQUEST_TXG, max_txg) != 0 ||
c8ee1847e300c992c76cf25d6c165e6ccf64a113Victor Latushkin nvlist_add_uint32(policy, ZPOOL_REWIND_REQUEST, rewind) != 0)
c8ee1847e300c992c76cf25d6c165e6ccf64a113Victor Latushkin fatal("internal error: %s", strerror(ENOMEM));
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin char *name = find_zpool(&target, &cfg, nsearch, searchdirs);
07428bdfb7bca7c9e74959692785555ea5e27ce2Victor Latushkin (void) printf("\nConfiguration for import:\n");
b702644a6eb66615d67b492fd73ecd9efa11fc7dTim Chase * Remove any trailing slash. Later code would get confused
b702644a6eb66615d67b492fd73ecd9efa11fc7dTim Chase * by it, but we want to allow it so that "pool/" can
b702644a6eb66615d67b492fd73ecd9efa11fc7dTim Chase * indicate that we want to dump the topmost filesystem,
b702644a6eb66615d67b492fd73ecd9efa11fc7dTim Chase * rather than the whole pool.
b702644a6eb66615d67b492fd73ecd9efa11fc7dTim Chase if (targetlen != 0 && target[targetlen - 1] == '/')
80eb36f241abf8c076119fb4c49a55fd61ebc710George Wilson error = spa_open_rewind(target, &spa, FTAG, policy,
8f18d1fadf6a0c20fac9ff7259a5368faa3c3bfbGeorge Wilson * If we're missing the log device then
8f18d1fadf6a0c20fac9ff7259a5368faa3c3bfbGeorge Wilson * try opening the pool after clearing the
07428bdfb7bca7c9e74959692785555ea5e27ce2Victor Latushkin error = dmu_objset_own(target, DMU_OST_ANY,
3ad6c7f96bc462dcbd2a112df698038f6764eabcVictor Latushkin fatal("can't open '%s': %s", target, strerror(error));
07428bdfb7bca7c9e74959692785555ea5e27ce2Victor Latushkin zopt_object = calloc(zopt_objects, sizeof (uint64_t));
07428bdfb7bca7c9e74959692785555ea5e27ce2Victor Latushkin for (i = 0; i < zopt_objects; i++) {
07428bdfb7bca7c9e74959692785555ea5e27ce2Victor Latushkin zopt_object[i] = strtoull(argv[i], NULL, 0);
e690fb27a7d1483f052505e1ff373d205f9dee99Christopher Siden } else if (zopt_objects > 0 && !dump_opt['m']) {
07428bdfb7bca7c9e74959692785555ea5e27ce2Victor Latushkin for (i = 0; i < argc; i++)
07428bdfb7bca7c9e74959692785555ea5e27ce2Victor Latushkin (os != NULL) ? dmu_objset_disown(os, FTAG) : spa_close(spa, FTAG);
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);