Skip to content

Commit

Permalink
zdb: temporarily work around dedup log object leak detection
Browse files Browse the repository at this point in the history
zdb doesn't yet understand the new dedup log objects, and decides they
are leaked blocks. This prevents ztest from working correctly.

This patch notices leaks when dedup log objects are in play, and ignores
them. This is a temporary patch until zdb is fixed, and should not be
merged.

Co-authored-by: Don Brady <don.brady@klarasystems.com>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Sponsored-by: iXsystems, Inc.
Sponsored-By: Klara Inc.
  • Loading branch information
robn and don-brady committed May 15, 2024
1 parent cdbcdfd commit 2004199
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -5450,6 +5450,7 @@ typedef struct zdb_cb {
uint32_t **zcb_vd_obsolete_counts;
avl_tree_t zcb_brt;
boolean_t zcb_brt_is_active;
boolean_t zcb_active_ddt_logs;
} zdb_cb_t;

/* test if two DVA offsets from same vdev are within the same metaslab */
Expand Down Expand Up @@ -6127,7 +6128,30 @@ zdb_ddt_leak_init(spa_t *spa, zdb_cb_t *zcb)
int error;

ASSERT(!dump_opt['L']);
#if 1
/*
* XXX - need to account for entries in the ddt logs
* For now we only detect that logs are not empty
*/
for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) {
ddt_t *ddt = spa->spa_ddt[c];
if (ddt == NULL)
continue;

if (avl_numnodes(&ddt->ddt_log_active->ddl_tree) > 0 ||
avl_numnodes(&ddt->ddt_log_flushing->ddl_tree) > 0) {
printf("zdb_ddt_leak_init: has active ddt logs\n");
zcb->zcb_active_ddt_logs = B_TRUE;
break;
}
if (ddt->ddt_log_active->ddl_object != 0 ||
ddt->ddt_log_flushing->ddl_object != 0) {
printf("zdb_ddt_leak_init: has ddt log objects\n");
zcb->zcb_active_ddt_logs = B_TRUE;
break;
}
}
#endif
while ((error = ddt_walk(spa, &ddb, &ddlwe)) == 0) {
blkptr_t blk;

Expand Down Expand Up @@ -6938,7 +6962,14 @@ dump_block_stats(spa_t *spa)
(u_longlong_t)total_alloc,
(dump_opt['L']) ? "unreachable" : "leaked",
(longlong_t)(total_alloc - total_found));
#if 1
/* XXX - need to account for entries in the ddt logs */
if (zcb->zcb_active_ddt_logs)
(void) printf("DDT log causing false positive leaks\n");
leaks = zcb->zcb_active_ddt_logs ? B_FALSE : B_TRUE;
#else
leaks = B_TRUE;
#endif
}

if (tzb->zb_count == 0) {
Expand Down Expand Up @@ -8031,6 +8062,21 @@ dump_mos_leaks(spa_t *spa)
}
}
}
#if 1
/* Account for FDT objects */
for (uint64_t cksum = 0; cksum < ZIO_CHECKSUM_FUNCTIONS; cksum++) {
ddt_t *ddt = spa->spa_ddt[cksum];
if (!ddt)
continue;
if (ddt->ddt_dir_object > 0)
mos_obj_refd(ddt->ddt_dir_object);

for (int log = 0; log < 2; log++) {
if (ddt->ddt_log[log].ddl_object > 0)
mos_obj_refd(ddt->ddt_log[log].ddl_object);
}
}
#endif

if (spa->spa_brt != NULL) {
brt_t *brt = spa->spa_brt;
Expand Down

0 comments on commit 2004199

Please sign in to comment.