Skip to content

Commit f45f2d6

Browse files
committed
Fix wrong dedup_table_size for legacy dedup
If we call ddt_log_load() for legacy ddt, we will end up going into ddt_log_update_stats() and filling uninitialized value into ddo_dspace. This value will then get added to dedup_table_size during ddt_get_dedup_object_stats(). Signed-off-by: Chunwei Chen <david.chen@nutanix.com> Fixes openzfs#17019
1 parent 69b65dd commit f45f2d6

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

module/zfs/ddt.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,9 +1701,11 @@ ddt_load(spa_t *spa)
17011701
}
17021702
}
17031703

1704-
error = ddt_log_load(ddt);
1705-
if (error != 0 && error != ENOENT)
1706-
return (error);
1704+
if (ddt->ddt_flags & DDT_FLAG_LOG) {
1705+
error = ddt_log_load(ddt);
1706+
if (error != 0 && error != ENOENT)
1707+
return (error);
1708+
}
17071709

17081710
DDT_KSTAT_SET(ddt, dds_log_active_entries,
17091711
avl_numnodes(&ddt->ddt_log_active->ddl_tree));

module/zfs/ddt_log.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,13 @@ ddt_log_update_stats(ddt_t *ddt)
176176
* that's reasonable to expect anyway.
177177
*/
178178
dmu_object_info_t doi;
179-
uint64_t nblocks;
180-
dmu_object_info(ddt->ddt_os, ddt->ddt_log_active->ddl_object, &doi);
181-
nblocks = doi.doi_physical_blocks_512;
182-
dmu_object_info(ddt->ddt_os, ddt->ddt_log_flushing->ddl_object, &doi);
183-
nblocks += doi.doi_physical_blocks_512;
179+
uint64_t nblocks = 0;
180+
if (dmu_object_info(ddt->ddt_os, ddt->ddt_log_active->ddl_object,
181+
&doi) == 0)
182+
nblocks += doi.doi_physical_blocks_512;
183+
if (dmu_object_info(ddt->ddt_os, ddt->ddt_log_flushing->ddl_object,
184+
&doi) == 0)
185+
nblocks += doi.doi_physical_blocks_512;
184186

185187
ddt_object_t *ddo = &ddt->ddt_log_stats;
186188
ddo->ddo_count =

0 commit comments

Comments
 (0)