Skip to content

Commit cff9f31

Browse files
committed
zdb: show dedup table and log attributes
There's interesting info in there that is going to help with understanding dedup behaviour at any given moment. Since this is a format change, tests that rely on that output have been modified to match. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Signed-off-by: Rob Norris <[email protected]>
1 parent d0a91b9 commit cff9f31

File tree

7 files changed

+93
-36
lines changed

7 files changed

+93
-36
lines changed

cmd/zdb/zdb.c

Lines changed: 80 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,17 +1967,51 @@ dump_dedup_ratio(const ddt_stat_t *dds)
19671967
static void
19681968
dump_ddt_log(ddt_t *ddt)
19691969
{
1970+
if (ddt->ddt_version != DDT_VERSION_FDT ||
1971+
!(ddt->ddt_flags & DDT_FLAG_LOG))
1972+
return;
1973+
19701974
for (int n = 0; n < 2; n++) {
19711975
ddt_log_t *ddl = &ddt->ddt_log[n];
19721976

1977+
char flagstr[64] = {0};
1978+
if (ddl->ddl_flags > 0) {
1979+
flagstr[0] = ' ';
1980+
int c = 1;
1981+
if (ddl->ddl_flags & DDL_FLAG_FLUSHING)
1982+
c += strlcpy(&flagstr[c], " FLUSHING",
1983+
sizeof (flagstr) - c);
1984+
if (ddl->ddl_flags & DDL_FLAG_CHECKPOINT)
1985+
c += strlcpy(&flagstr[c], " CHECKPOINT",
1986+
sizeof (flagstr) - c);
1987+
if (ddl->ddl_flags &
1988+
~(DDL_FLAG_FLUSHING|DDL_FLAG_CHECKPOINT))
1989+
c += strlcpy(&flagstr[c], " UNKNOWN",
1990+
sizeof (flagstr) - c);
1991+
flagstr[1] = '[';
1992+
flagstr[c++] = ']';
1993+
}
1994+
19731995
uint64_t count = avl_numnodes(&ddl->ddl_tree);
1974-
if (count == 0)
1975-
continue;
19761996

1977-
printf(DMU_POOL_DDT_LOG ": %lu log entries\n",
1978-
zio_checksum_table[ddt->ddt_checksum].ci_name, n, count);
1997+
printf(DMU_POOL_DDT_LOG ": flags=0x%02x%s; obj=%lu; "
1998+
"len=%lu; txg=%lu; entries=%lu\n",
1999+
zio_checksum_table[ddt->ddt_checksum].ci_name, n,
2000+
ddl->ddl_flags, flagstr, ddl->ddl_object,
2001+
ddl->ddl_length, ddl->ddl_first_txg, count);
2002+
2003+
if (ddl->ddl_flags & DDL_FLAG_CHECKPOINT) {
2004+
const ddt_key_t *ddk = &ddl->ddl_checkpoint;
2005+
printf(" checkpoint: "
2006+
"%016llx:%016llx:%016llx:%016llx:%016llx\n",
2007+
(u_longlong_t)ddk->ddk_cksum.zc_word[0],
2008+
(u_longlong_t)ddk->ddk_cksum.zc_word[1],
2009+
(u_longlong_t)ddk->ddk_cksum.zc_word[2],
2010+
(u_longlong_t)ddk->ddk_cksum.zc_word[3],
2011+
(u_longlong_t)ddk->ddk_prop);
2012+
}
19792013

1980-
if (dump_opt['D'] < 4)
2014+
if (count == 0 || dump_opt['D'] < 4)
19812015
continue;
19822016

19832017
ddt_lightweight_entry_t ddlwe;
@@ -1991,7 +2025,7 @@ dump_ddt_log(ddt_t *ddt)
19912025
}
19922026

19932027
static void
1994-
dump_ddt(ddt_t *ddt, ddt_type_t type, ddt_class_t class)
2028+
dump_ddt_object(ddt_t *ddt, ddt_type_t type, ddt_class_t class)
19952029
{
19962030
char name[DDT_NAMELEN];
19972031
ddt_lightweight_entry_t ddlwe;
@@ -2016,11 +2050,8 @@ dump_ddt(ddt_t *ddt, ddt_type_t type, ddt_class_t class)
20162050

20172051
ddt_object_name(ddt, type, class, name);
20182052

2019-
(void) printf("%s: %llu entries, size %llu on disk, %llu in core\n",
2020-
name,
2021-
(u_longlong_t)count,
2022-
(u_longlong_t)dspace,
2023-
(u_longlong_t)mspace);
2053+
(void) printf("%s: dspace=%llu; mspace=%llu; entries=%llu\n", name,
2054+
(u_longlong_t)dspace, (u_longlong_t)mspace, (u_longlong_t)count);
20242055

20252056
if (dump_opt['D'] < 3)
20262057
return;
@@ -2043,24 +2074,50 @@ dump_ddt(ddt_t *ddt, ddt_type_t type, ddt_class_t class)
20432074
(void) printf("\n");
20442075
}
20452076

2077+
static void
2078+
dump_ddt(ddt_t *ddt)
2079+
{
2080+
if (!ddt || ddt->ddt_version == DDT_VERSION_UNCONFIGURED)
2081+
return;
2082+
2083+
char flagstr[64] = {0};
2084+
if (ddt->ddt_flags > 0) {
2085+
flagstr[0] = ' ';
2086+
int c = 1;
2087+
if (ddt->ddt_flags & DDT_FLAG_FLAT)
2088+
c += strlcpy(&flagstr[c], " FLAT",
2089+
sizeof (flagstr) - c);
2090+
if (ddt->ddt_flags & DDT_FLAG_LOG)
2091+
c += strlcpy(&flagstr[c], " LOG",
2092+
sizeof (flagstr) - c);
2093+
if (ddt->ddt_flags & ~DDT_FLAG_MASK)
2094+
c += strlcpy(&flagstr[c], " UNKNOWN",
2095+
sizeof (flagstr) - c);
2096+
flagstr[1] = '[';
2097+
flagstr[c] = ']';
2098+
}
2099+
2100+
printf("DDT-%s: version=%lu [%s]; flags=0x%02lx%s; rootobj=%lu\n",
2101+
zio_checksum_table[ddt->ddt_checksum].ci_name, ddt->ddt_version,
2102+
(ddt->ddt_version == 0) ? "LEGACY" :
2103+
(ddt->ddt_version == 1) ? "FDT" : "UNKNOWN",
2104+
ddt->ddt_flags, flagstr, ddt->ddt_dir_object);
2105+
2106+
for (ddt_type_t type = 0; type < DDT_TYPES; type++)
2107+
for (ddt_class_t class = 0; class < DDT_CLASSES; class++)
2108+
dump_ddt_object(ddt, type, class);
2109+
2110+
dump_ddt_log(ddt);
2111+
}
2112+
20462113
static void
20472114
dump_all_ddts(spa_t *spa)
20482115
{
20492116
ddt_histogram_t ddh_total = {{{0}}};
20502117
ddt_stat_t dds_total = {0};
20512118

2052-
for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) {
2053-
ddt_t *ddt = spa->spa_ddt[c];
2054-
if (!ddt || ddt->ddt_version == DDT_VERSION_UNCONFIGURED)
2055-
continue;
2056-
for (ddt_type_t type = 0; type < DDT_TYPES; type++) {
2057-
for (ddt_class_t class = 0; class < DDT_CLASSES;
2058-
class++) {
2059-
dump_ddt(ddt, type, class);
2060-
}
2061-
}
2062-
dump_ddt_log(ddt);
2063-
}
2119+
for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++)
2120+
dump_ddt(spa->spa_ddt[c]);
20642121

20652122
ddt_get_dedup_stats(spa, &dds_total);
20662123

tests/zfs-tests/tests/functional/dedup/dedup_fdt_create.ksh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ log_must zpool sync
7070
log_must test $(get_pool_prop feature@fast_dedup $TESTPOOL) = "active"
7171

7272
# four entries in the unique table
73-
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique: 4 entries'"
73+
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique:.*entries=4'"
7474

7575
# single containing object in the MOS
7676
log_must test $(zdb -dddd $TESTPOOL 1 | grep DDT-sha256 | wc -l) -eq 1
@@ -84,7 +84,7 @@ log_must cp /$TESTPOOL/file1 /$TESTPOOL/file2
8484
log_must zpool sync
8585

8686
# now four entries in the duplicate table
87-
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-duplicate: 4 entries'"
87+
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-duplicate:.*entries=4'"
8888

8989
# now two DDT ZAPs in the container object; DDT ZAPs aren't cleaned up until
9090
# the entire logical table is destroyed

tests/zfs-tests/tests/functional/dedup/dedup_fdt_import.ksh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ log_must zpool sync
7070
log_must test $(get_pool_prop feature@fast_dedup $TESTPOOL) = "active"
7171

7272
# four entries in the unique table
73-
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique: 4 entries'"
73+
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique:.*entries=4'"
7474

7575
# single containing object in the MOS
7676
log_must test $(zdb -dddd $TESTPOOL 1 | grep DDT-sha256 | wc -l) -eq 1
@@ -107,7 +107,7 @@ log_must zpool sync
107107
log_must test $(get_pool_prop feature@fast_dedup $TESTPOOL) = "active"
108108

109109
# four entries in the unique table
110-
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique: 4 entries'"
110+
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique:.*entries=4'"
111111

112112
# single containing object in the MOS
113113
log_must test $(zdb -dddd $TESTPOOL 1 | grep DDT-sha256 | wc -l) -eq 1

tests/zfs-tests/tests/functional/dedup/dedup_legacy_create.ksh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ log_must zpool sync
6363
log_must test $(get_pool_prop feature@fast_dedup $TESTPOOL) = "disabled"
6464

6565
# should be four entries in the unique table
66-
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique: 4 entries'"
66+
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique:.*entries=4'"
6767

6868
# should be just one DDT ZAP in the MOS
6969
log_must test $(zdb -dddd $TESTPOOL 1 | grep DDT-sha256-zap- | wc -l) -eq 1
@@ -73,7 +73,7 @@ log_must cp /$TESTPOOL/file1 /$TESTPOOL/file2
7373
log_must zpool sync
7474

7575
# now four entries in the duplicate table
76-
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-duplicate: 4 entries'"
76+
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-duplicate:.*entries=4'"
7777

7878
# now two DDT ZAPs in the MOS; DDT ZAPs aren't cleaned up until the entire
7979
# logical table is destroyed

tests/zfs-tests/tests/functional/dedup/dedup_legacy_fdt_mixed.ksh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ log_must dd if=/dev/urandom of=/$TESTPOOL/ds1/file1 bs=128k count=4
7171
log_must zpool sync
7272

7373
# should be four entries in the skein unique table
74-
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-skein-zap-unique: 4 entries'"
74+
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-skein-zap-unique:.*entries=4'"
7575

7676
# should be just one DDT ZAP in the MOS
7777
log_must test $(zdb -dddd $TESTPOOL 1 | grep DDT-.*-zap- | wc -l) -eq 1
@@ -90,7 +90,7 @@ log_must zpool sync
9090
log_must test $(get_pool_prop feature@fast_dedup $TESTPOOL) = "active"
9191

9292
# now also four entries in the blake3 unique table
93-
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-blake3-zap-unique: 4 entries'"
93+
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-blake3-zap-unique:.*entries=4'"
9494

9595
# two entries in the MOS: the legacy skein DDT ZAP, and the containing dir for
9696
# the blake3 FDT table

tests/zfs-tests/tests/functional/dedup/dedup_legacy_fdt_upgrade.ksh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ log_must zpool sync
7171
log_must test $(get_pool_prop feature@fast_dedup $TESTPOOL) = "disabled"
7272

7373
# should be four entries in the unique table
74-
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique: 4 entries'"
74+
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique:.*entries=4'"
7575

7676
# should be just one DDT ZAP in the MOS
7777
log_must test $(zdb -dddd $TESTPOOL 1 | grep DDT-sha256-zap- | wc -l) -eq 1
@@ -90,7 +90,7 @@ log_must zpool sync
9090
log_must test $(get_pool_prop feature@fast_dedup $TESTPOOL) = "enabled"
9191

9292
# now four entries in the duplicate table
93-
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-duplicate: 4 entries'"
93+
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-duplicate:.*entries=4'"
9494

9595
# now two DDT ZAPs in the MOS; DDT ZAPs aren't cleaned up until the entire
9696
# logical table is destroyed
@@ -117,7 +117,7 @@ log_must zpool sync
117117
log_must test $(get_pool_prop feature@fast_dedup $TESTPOOL) = "active"
118118

119119
# four entries in the unique table
120-
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique: 4 entries'"
120+
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique:.*entries=4'"
121121

122122
# single containing object in the MOS
123123
log_must test $(zdb -dddd $TESTPOOL 1 | grep DDT-sha256 | wc -l) -eq 1

tests/zfs-tests/tests/functional/dedup/dedup_legacy_import.ksh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ log_must zpool sync
6363
log_must test $(get_pool_prop feature@fast_dedup $TESTPOOL) = "disabled"
6464

6565
# should be four entries in the unique table
66-
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique: 4 entries'"
66+
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique:.*entries=4'"
6767

6868
# should be just one DDT ZAP in the MOS
6969
log_must test $(zdb -dddd $TESTPOOL 1 | grep DDT-sha256-zap- | wc -l) -eq 1
@@ -96,7 +96,7 @@ log_must zpool sync
9696
log_must test $(get_pool_prop feature@fast_dedup $TESTPOOL) = "disabled"
9797

9898
# should be four entries in the unique table
99-
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique: 4 entries'"
99+
log_must eval "zdb -D $TESTPOOL | grep -q 'DDT-sha256-zap-unique:.*entries=4'"
100100

101101
# should be just one DDT ZAP in the MOS
102102
log_must test $(zdb -dddd $TESTPOOL 1 | grep DDT-sha256-zap- | wc -l) -eq 1

0 commit comments

Comments
 (0)