Skip to content

Commit

Permalink
Merge pull request openzfs#618 from delphix/projects/merge-upstream/m…
Browse files Browse the repository at this point in the history
…aster

Merge remote-tracking branch '6.0/stage' into 'master'
  • Loading branch information
delphix-devops-bot authored Sep 16, 2022
2 parents 7efe4e9 + 645121a commit 3d343c4
Show file tree
Hide file tree
Showing 97 changed files with 2,290 additions and 509 deletions.
7 changes: 4 additions & 3 deletions cmd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,13 @@ endif


if USING_PYTHON
bin_SCRIPTS += arc_summary arcstat dbufstat
CLEANFILES += arc_summary arcstat dbufstat
dist_noinst_DATA += %D%/arc_summary %D%/arcstat.in %D%/dbufstat.in
bin_SCRIPTS += arc_summary arcstat dbufstat zilstat
CLEANFILES += arc_summary arcstat dbufstat zilstat
dist_noinst_DATA += %D%/arc_summary %D%/arcstat.in %D%/dbufstat.in %D%/zilstat.in

$(call SUBST,arcstat,%D%/)
$(call SUBST,dbufstat,%D%/)
$(call SUBST,zilstat,%D%/)
arc_summary: %D%/arc_summary
$(AM_V_at)cp $< $@
endif
Expand Down
81 changes: 45 additions & 36 deletions cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -6445,7 +6445,7 @@ deleted_livelists_dump_mos(spa_t *spa)
static int
dump_block_stats(spa_t *spa)
{
zdb_cb_t zcb = {{{{0}}}};
zdb_cb_t *zcb;
zdb_blkstats_t *zb, *tzb;
uint64_t norm_alloc, norm_space, total_alloc, total_found;
int flags = TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA |
Expand All @@ -6454,6 +6454,8 @@ dump_block_stats(spa_t *spa)
int e, c, err;
bp_embedded_type_t i;

zcb = umem_zalloc(sizeof (zdb_cb_t), UMEM_NOFAIL);

/*
* For an objectstore based zpool, there are no space maps and zdb leak
* detection will not work.
Expand Down Expand Up @@ -6483,39 +6485,39 @@ dump_block_stats(spa_t *spa)
* pool claiming each block we discover, but we skip opening any space
* maps.
*/
zdb_leak_init(spa, &zcb);
zdb_leak_init(spa, zcb);

/*
* If there's a deferred-free bplist, process that first.
*/
(void) bpobj_iterate_nofree(&spa->spa_deferred_bpobj,
bpobj_count_block_cb, &zcb, NULL);
bpobj_count_block_cb, zcb, NULL);

if (spa_version(spa) >= SPA_VERSION_DEADLISTS) {
(void) bpobj_iterate_nofree(&spa->spa_dsl_pool->dp_free_bpobj,
bpobj_count_block_cb, &zcb, NULL);
bpobj_count_block_cb, zcb, NULL);
}

zdb_claim_removing(spa, &zcb);
zdb_claim_removing(spa, zcb);

if (spa_feature_is_active(spa, SPA_FEATURE_ASYNC_DESTROY)) {
VERIFY3U(0, ==, bptree_iterate(spa->spa_meta_objset,
spa->spa_dsl_pool->dp_bptree_obj, B_FALSE, count_block_cb,
&zcb, NULL));
zcb, NULL));
}

deleted_livelists_count_blocks(spa, &zcb);
deleted_livelists_count_blocks(spa, zcb);

if (dump_opt['c'] > 1)
flags |= TRAVERSE_PREFETCH_DATA;

zcb.zcb_totalasize = metaslab_class_get_alloc(spa_normal_class(spa));
zcb.zcb_totalasize += metaslab_class_get_alloc(spa_special_class(spa));
zcb.zcb_totalasize += metaslab_class_get_alloc(spa_dedup_class(spa));
zcb.zcb_totalasize +=
zcb->zcb_totalasize = metaslab_class_get_alloc(spa_normal_class(spa));
zcb->zcb_totalasize += metaslab_class_get_alloc(spa_special_class(spa));
zcb->zcb_totalasize += metaslab_class_get_alloc(spa_dedup_class(spa));
zcb->zcb_totalasize +=
metaslab_class_get_alloc(spa_embedded_log_class(spa));
zcb.zcb_start = zcb.zcb_lastprint = gethrtime();
err = traverse_pool(spa, 0, flags, zdb_blkptr_cb, &zcb);
zcb->zcb_start = zcb->zcb_lastprint = gethrtime();
err = traverse_pool(spa, 0, flags, zdb_blkptr_cb, zcb);

/*
* If we've traversed the data blocks then we need to wait for those
Expand All @@ -6536,25 +6538,25 @@ dump_block_stats(spa_t *spa)
* Done after zio_wait() since zcb_haderrors is modified in
* zdb_blkptr_done()
*/
zcb.zcb_haderrors |= err;
zcb->zcb_haderrors |= err;

if (zcb.zcb_haderrors) {
if (zcb->zcb_haderrors) {
(void) printf("\nError counts:\n\n");
(void) printf("\t%5s %s\n", "errno", "count");
for (e = 0; e < 256; e++) {
if (zcb.zcb_errors[e] != 0) {
if (zcb->zcb_errors[e] != 0) {
(void) printf("\t%5d %llu\n",
e, (u_longlong_t)zcb.zcb_errors[e]);
e, (u_longlong_t)zcb->zcb_errors[e]);
}
}
}

/*
* Report any leaked segments.
*/
leaks |= zdb_leak_fini(spa, &zcb);
leaks |= zdb_leak_fini(spa, zcb);

tzb = &zcb.zcb_type[ZB_TOTAL][ZDB_OT_TOTAL];
tzb = &zcb->zcb_type[ZB_TOTAL][ZDB_OT_TOTAL];

norm_alloc = metaslab_class_get_alloc(spa_normal_class(spa));
norm_space = metaslab_class_get_space(spa_normal_class(spa));
Expand All @@ -6565,8 +6567,8 @@ dump_block_stats(spa_t *spa)
metaslab_class_get_alloc(spa_special_class(spa)) +
metaslab_class_get_alloc(spa_dedup_class(spa)) +
get_unflushed_alloc_space(spa);
total_found = tzb->zb_asize - zcb.zcb_dedup_asize +
zcb.zcb_removing_size + zcb.zcb_checkpoint_size;
total_found = tzb->zb_asize - zcb->zcb_dedup_asize +
zcb->zcb_removing_size + zcb->zcb_checkpoint_size;

if (total_found == total_alloc && !dump_opt['L']) {
(void) printf("\n\tNo leaks (block sum matches space"
Expand All @@ -6581,8 +6583,10 @@ dump_block_stats(spa_t *spa)
leaks = B_TRUE;
}

if (tzb->zb_count == 0)
if (tzb->zb_count == 0) {
umem_free(zcb, sizeof (zdb_cb_t));
return (2);
}

(void) printf("\n");
(void) printf("\t%-16s %14llu\n", "bp count:",
Expand All @@ -6601,9 +6605,9 @@ dump_block_stats(spa_t *spa)
(u_longlong_t)(tzb->zb_asize / tzb->zb_count),
(double)tzb->zb_lsize / tzb->zb_asize);
(void) printf("\t%-16s %14llu ref>1: %6llu deduplication: %6.2f\n",
"bp deduped:", (u_longlong_t)zcb.zcb_dedup_asize,
(u_longlong_t)zcb.zcb_dedup_blocks,
(double)zcb.zcb_dedup_asize / tzb->zb_asize + 1.0);
"bp deduped:", (u_longlong_t)zcb->zcb_dedup_asize,
(u_longlong_t)zcb->zcb_dedup_blocks,
(double)zcb->zcb_dedup_asize / tzb->zb_asize + 1.0);
(void) printf("\t%-16s %14llu used: %5.2f%%\n", "Normal class:",
(u_longlong_t)norm_alloc, 100.0 * norm_alloc / norm_space);

Expand Down Expand Up @@ -6641,19 +6645,19 @@ dump_block_stats(spa_t *spa)
}

for (i = 0; i < NUM_BP_EMBEDDED_TYPES; i++) {
if (zcb.zcb_embedded_blocks[i] == 0)
if (zcb->zcb_embedded_blocks[i] == 0)
continue;
(void) printf("\n");
(void) printf("\tadditional, non-pointer bps of type %u: "
"%10llu\n",
i, (u_longlong_t)zcb.zcb_embedded_blocks[i]);
i, (u_longlong_t)zcb->zcb_embedded_blocks[i]);

if (dump_opt['b'] >= 3) {
(void) printf("\t number of (compressed) bytes: "
"number of bps\n");
dump_histogram(zcb.zcb_embedded_histogram[i],
sizeof (zcb.zcb_embedded_histogram[i]) /
sizeof (zcb.zcb_embedded_histogram[i][0]), 0);
dump_histogram(zcb->zcb_embedded_histogram[i],
sizeof (zcb->zcb_embedded_histogram[i]) /
sizeof (zcb->zcb_embedded_histogram[i][0]), 0);
}
}

Expand Down Expand Up @@ -6713,7 +6717,7 @@ dump_block_stats(spa_t *spa)
else
typename = zdb_ot_extname[t - DMU_OT_NUMTYPES];

if (zcb.zcb_type[ZB_TOTAL][t].zb_asize == 0) {
if (zcb->zcb_type[ZB_TOTAL][t].zb_asize == 0) {
(void) printf("%6s\t%5s\t%5s\t%5s"
"\t%5s\t%5s\t%6s\t%s\n",
"-",
Expand All @@ -6729,7 +6733,7 @@ dump_block_stats(spa_t *spa)

for (l = ZB_TOTAL - 1; l >= -1; l--) {
level = (l == -1 ? ZB_TOTAL : l);
zb = &zcb.zcb_type[level][t];
zb = &zcb->zcb_type[level][t];

if (zb->zb_asize == 0)
continue;
Expand All @@ -6738,7 +6742,7 @@ dump_block_stats(spa_t *spa)
continue;

if (level == 0 && zb->zb_asize ==
zcb.zcb_type[ZB_TOTAL][t].zb_asize)
zcb->zcb_type[ZB_TOTAL][t].zb_asize)
continue;

zdb_nicenum(zb->zb_count, csize,
Expand Down Expand Up @@ -6782,18 +6786,23 @@ dump_block_stats(spa_t *spa)

/* Output a table summarizing block sizes in the pool */
if (dump_opt['b'] >= 2) {
dump_size_histograms(&zcb);
dump_size_histograms(zcb);
}
}

(void) printf("\n");

if (leaks)
if (leaks) {
umem_free(zcb, sizeof (zdb_cb_t));
return (2);
}

if (zcb.zcb_haderrors)
if (zcb->zcb_haderrors) {
umem_free(zcb, sizeof (zdb_cb_t));
return (3);
}

umem_free(zcb, sizeof (zdb_cb_t));
return (0);
}

Expand Down
Loading

0 comments on commit 3d343c4

Please sign in to comment.