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().

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Closes #17019
Closes #17699

Signed-off-by: Chunwei Chen <david.chen@nutanix.com>
Co-authored-by: Chunwei Chen <david.chen@nutanix.com>
This commit is contained in:
Chunwei Chen
2025-09-08 14:02:51 -07:00
committed by Brian Behlendorf
parent 34ca2b8392
commit c755aa486d
2 changed files with 12 additions and 8 deletions
+7 -5
View File
@@ -176,11 +176,13 @@ ddt_log_update_stats(ddt_t *ddt)
* that's reasonable to expect anyway.
*/
dmu_object_info_t doi;
uint64_t nblocks;
dmu_object_info(ddt->ddt_os, ddt->ddt_log_active->ddl_object, &doi);
nblocks = doi.doi_physical_blocks_512;
dmu_object_info(ddt->ddt_os, ddt->ddt_log_flushing->ddl_object, &doi);
nblocks += doi.doi_physical_blocks_512;
uint64_t nblocks = 0;
if (dmu_object_info(ddt->ddt_os, ddt->ddt_log_active->ddl_object,
&doi) == 0)
nblocks += doi.doi_physical_blocks_512;
if (dmu_object_info(ddt->ddt_os, ddt->ddt_log_flushing->ddl_object,
&doi) == 0)
nblocks += doi.doi_physical_blocks_512;
ddt_object_t *ddo = &ddt->ddt_log_stats;
ddo->ddo_count =