zdb: add extra -T flag to show histograms of BRT refcounts

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes #16692
This commit is contained in:
Rob Norris 2024-11-02 03:08:33 +11:00 committed by GitHub
parent acb6e71eda
commit 673efbbf5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 6 deletions

View File

@ -2152,7 +2152,12 @@ dump_brt(spa_t *spa)
if (dump_opt['T'] < 3) if (dump_opt['T'] < 3)
return; return;
/* -TTT shows a per-vdev histograms; -TTTT shows all entries */
boolean_t do_histo = dump_opt['T'] == 3;
char dva[64]; char dva[64];
if (!do_histo)
printf("\n%-16s %-10s\n", "DVA", "REFCNT"); printf("\n%-16s %-10s\n", "DVA", "REFCNT");
for (uint64_t vdevid = 0; vdevid < brt->brt_nvdevs; vdevid++) { for (uint64_t vdevid = 0; vdevid < brt->brt_nvdevs; vdevid++) {
@ -2160,6 +2165,8 @@ dump_brt(spa_t *spa)
if (brtvd == NULL || !brtvd->bv_initiated) if (brtvd == NULL || !brtvd->bv_initiated)
continue; continue;
uint64_t counts[64] = {};
zap_cursor_t zc; zap_cursor_t zc;
zap_attribute_t *za = zap_attribute_alloc(); zap_attribute_t *za = zap_attribute_alloc();
for (zap_cursor_init(&zc, brt->brt_mos, brtvd->bv_mos_entries); for (zap_cursor_init(&zc, brt->brt_mos, brtvd->bv_mos_entries);
@ -2172,14 +2179,26 @@ dump_brt(spa_t *spa)
za->za_integer_length, za->za_num_integers, za->za_integer_length, za->za_num_integers,
&refcnt)); &refcnt));
uint64_t offset = *(const uint64_t *)za->za_name; if (do_histo)
counts[highbit64(refcnt)]++;
else {
uint64_t offset =
*(const uint64_t *)za->za_name;
snprintf(dva, sizeof (dva), "%" PRIu64 ":%llx", vdevid, snprintf(dva, sizeof (dva), "%" PRIu64 ":%llx",
(u_longlong_t)offset); vdevid, (u_longlong_t)offset);
printf("%-16s %-10llu\n", dva, (u_longlong_t)refcnt); printf("%-16s %-10llu\n", dva,
(u_longlong_t)refcnt);
}
} }
zap_cursor_fini(&zc); zap_cursor_fini(&zc);
zap_attribute_free(za); zap_attribute_free(za);
if (do_histo) {
printf("\nBRT: vdev %" PRIu64
": DVAs with 2^n refcnts:\n", vdevid);
dump_histogram(counts, 64, 0);
}
} }
} }

View File

@ -14,7 +14,7 @@
.\" Copyright (c) 2017 Lawrence Livermore National Security, LLC. .\" Copyright (c) 2017 Lawrence Livermore National Security, LLC.
.\" Copyright (c) 2017 Intel Corporation. .\" Copyright (c) 2017 Intel Corporation.
.\" .\"
.Dd November 18, 2023 .Dd October 27, 2024
.Dt ZDB 8 .Dt ZDB 8
.Os .Os
. .
@ -408,6 +408,8 @@ blocks cloned, the space saving as a result of cloning, and the saving ratio.
.It Fl TT .It Fl TT
Display the per-vdev BRT statistics, including total references. Display the per-vdev BRT statistics, including total references.
.It Fl TTT .It Fl TTT
Display histograms of per-vdev BRT refcounts.
.It Fl TTTT
Dump the contents of the block reference tables. Dump the contents of the block reference tables.
.It Fl u , -uberblock .It Fl u , -uberblock
Display the current uberblock. Display the current uberblock.