zdb.c (a2cdcdd260232b58202b11a9bfc0103c9449ed52) zdb.c (ca0cc3918a1789fa839194af2a9245f801a06b1a)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 7 unchanged lines hidden (view full) ---

16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 7 unchanged lines hidden (view full) ---

16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
24 * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
25 */
26
27#include <stdio.h>
28#include <unistd.h>
29#include <stdio_ext.h>
30#include <stdlib.h>
31#include <ctype.h>
32#include <sys/zfs_context.h>

--- 2160 unchanged lines hidden (view full) ---

2193 if (dump_opt['u'])
2194 dump_label_uberblocks(&label, ashift);
2195 }
2196
2197 free(path);
2198 (void) close(fd);
2199}
2200
25 */
26
27#include <stdio.h>
28#include <unistd.h>
29#include <stdio_ext.h>
30#include <stdlib.h>
31#include <ctype.h>
32#include <sys/zfs_context.h>

--- 2160 unchanged lines hidden (view full) ---

2193 if (dump_opt['u'])
2194 dump_label_uberblocks(&label, ashift);
2195 }
2196
2197 free(path);
2198 (void) close(fd);
2199}
2200
2201static uint64_t num_large_blocks;
2201static uint64_t dataset_feature_count[SPA_FEATURES];
2202
2203/*ARGSUSED*/
2204static int
2205dump_one_dir(const char *dsname, void *arg)
2206{
2207 int error;
2208 objset_t *os;
2209
2210 error = dmu_objset_own(dsname, DMU_OST_ANY, B_TRUE, FTAG, &os);
2211 if (error) {
2212 (void) printf("Could not open %s, error %d\n", dsname, error);
2213 return (0);
2214 }
2202
2203/*ARGSUSED*/
2204static int
2205dump_one_dir(const char *dsname, void *arg)
2206{
2207 int error;
2208 objset_t *os;
2209
2210 error = dmu_objset_own(dsname, DMU_OST_ANY, B_TRUE, FTAG, &os);
2211 if (error) {
2212 (void) printf("Could not open %s, error %d\n", dsname, error);
2213 return (0);
2214 }
2215 if (dmu_objset_ds(os)->ds_large_blocks)
2216 num_large_blocks++;
2215
2216 for (spa_feature_t f = 0; f < SPA_FEATURES; f++) {
2217 if (!dmu_objset_ds(os)->ds_feature_inuse[f])
2218 continue;
2219 ASSERT(spa_feature_table[f].fi_flags &
2220 ZFEATURE_FLAG_PER_DATASET);
2221 dataset_feature_count[f]++;
2222 }
2223
2217 dump_dir(os);
2218 dmu_objset_disown(os, FTAG);
2219 fuid_table_destroy();
2220 sa_loaded = B_FALSE;
2221 return (0);
2222}
2223
2224/*

--- 780 unchanged lines hidden (view full) ---

3005 dump_all_ddts(spa);
3006
3007 if (dump_opt['d'] > 2 || dump_opt['m'])
3008 dump_metaslabs(spa);
3009 if (dump_opt['M'])
3010 dump_metaslab_groups(spa);
3011
3012 if (dump_opt['d'] || dump_opt['i']) {
2224 dump_dir(os);
2225 dmu_objset_disown(os, FTAG);
2226 fuid_table_destroy();
2227 sa_loaded = B_FALSE;
2228 return (0);
2229}
2230
2231/*

--- 780 unchanged lines hidden (view full) ---

3012 dump_all_ddts(spa);
3013
3014 if (dump_opt['d'] > 2 || dump_opt['m'])
3015 dump_metaslabs(spa);
3016 if (dump_opt['M'])
3017 dump_metaslab_groups(spa);
3018
3019 if (dump_opt['d'] || dump_opt['i']) {
3013 uint64_t refcount;
3014 dump_dir(dp->dp_meta_objset);
3015 if (dump_opt['d'] >= 3) {
3016 dump_full_bpobj(&spa->spa_deferred_bpobj,
3017 "Deferred frees", 0);
3018 if (spa_version(spa) >= SPA_VERSION_DEADLISTS) {
3019 dump_full_bpobj(
3020 &spa->spa_dsl_pool->dp_free_bpobj,
3021 "Pool snapshot frees", 0);

--- 5 unchanged lines hidden (view full) ---

3027 spa->spa_dsl_pool->dp_bptree_obj,
3028 "Pool dataset frees");
3029 }
3030 dump_dtl(spa->spa_root_vdev, 0);
3031 }
3032 (void) dmu_objset_find(spa_name(spa), dump_one_dir,
3033 NULL, DS_FIND_SNAPSHOTS | DS_FIND_CHILDREN);
3034
3020 dump_dir(dp->dp_meta_objset);
3021 if (dump_opt['d'] >= 3) {
3022 dump_full_bpobj(&spa->spa_deferred_bpobj,
3023 "Deferred frees", 0);
3024 if (spa_version(spa) >= SPA_VERSION_DEADLISTS) {
3025 dump_full_bpobj(
3026 &spa->spa_dsl_pool->dp_free_bpobj,
3027 "Pool snapshot frees", 0);

--- 5 unchanged lines hidden (view full) ---

3033 spa->spa_dsl_pool->dp_bptree_obj,
3034 "Pool dataset frees");
3035 }
3036 dump_dtl(spa->spa_root_vdev, 0);
3037 }
3038 (void) dmu_objset_find(spa_name(spa), dump_one_dir,
3039 NULL, DS_FIND_SNAPSHOTS | DS_FIND_CHILDREN);
3040
3035 (void) feature_get_refcount(spa,
3036 &spa_feature_table[SPA_FEATURE_LARGE_BLOCKS], &refcount);
3037 if (num_large_blocks != refcount) {
3038 (void) printf("large_blocks feature refcount mismatch: "
3039 "expected %lld != actual %lld\n",
3040 (longlong_t)num_large_blocks,
3041 (longlong_t)refcount);
3042 rc = 2;
3043 } else {
3044 (void) printf("Verified large_blocks feature refcount "
3045 "is correct (%llu)\n", (longlong_t)refcount);
3041 for (spa_feature_t f = 0; f < SPA_FEATURES; f++) {
3042 uint64_t refcount;
3043
3044 if (!(spa_feature_table[f].fi_flags &
3045 ZFEATURE_FLAG_PER_DATASET)) {
3046 ASSERT0(dataset_feature_count[f]);
3047 continue;
3048 }
3049 (void) feature_get_refcount(spa,
3050 &spa_feature_table[f], &refcount);
3051 if (dataset_feature_count[f] != refcount) {
3052 (void) printf("%s feature refcount mismatch: "
3053 "%lld datasets != %lld refcount\n",
3054 spa_feature_table[f].fi_uname,
3055 (longlong_t)dataset_feature_count[f],
3056 (longlong_t)refcount);
3057 rc = 2;
3058 } else {
3059 (void) printf("Verified %s feature refcount "
3060 "of %llu is correct\n",
3061 spa_feature_table[f].fi_uname,
3062 (longlong_t)refcount);
3063 }
3046 }
3047 }
3048 if (rc == 0 && (dump_opt['b'] || dump_opt['c']))
3049 rc = dump_block_stats(spa);
3050
3051 if (rc == 0)
3052 rc = verify_spacemap_refcounts(spa);
3053

--- 706 unchanged lines hidden ---
3064 }
3065 }
3066 if (rc == 0 && (dump_opt['b'] || dump_opt['c']))
3067 rc = dump_block_stats(spa);
3068
3069 if (rc == 0)
3070 rc = verify_spacemap_refcounts(spa);
3071

--- 706 unchanged lines hidden ---