aboutsummaryrefslogtreecommitdiff
path: root/module/zfs/ddt.c
diff options
context:
space:
mode:
authorGvozden Neskovic <neskovic@gmail.com>2016-12-02 23:59:35 +0000
committerBrian Behlendorf <behlendorf1@llnl.gov>2016-12-02 23:59:35 +0000
commite8a2014436147d07442e52f854e197082748fca6 (patch)
tree45eabe29ed4c7848ffe15f81e09d1e948096828b /module/zfs/ddt.c
parentbaf67d15a59025fb53fc60bf439ef291397366e8 (diff)
downloadsrc-e8a2014436147d07442e52f854e197082748fca6.tar.gz
src-e8a2014436147d07442e52f854e197082748fca6.zip
Cache ddt_get_dedup_dspace() value if there was no ddt changes
Save and reuse ddt dspace calculation when there have been no ddt changes. This avoids unnecessary traversal of 168KiB of ddt histograms. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Gvozden Neskovic <neskovic@gmail.com> Closes #5425
Diffstat (limited to 'module/zfs/ddt.c')
-rw-r--r--module/zfs/ddt.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/module/zfs/ddt.c b/module/zfs/ddt.c
index cbec70057ef7..75ab7f5b26e1 100644
--- a/module/zfs/ddt.c
+++ b/module/zfs/ddt.c
@@ -529,10 +529,17 @@ ddt_get_dedup_stats(spa_t *spa, ddt_stat_t *dds_total)
uint64_t
ddt_get_dedup_dspace(spa_t *spa)
{
- ddt_stat_t dds_total = { 0 };
+ ddt_stat_t dds_total;
+
+ if (spa->spa_dedup_dspace != ~0ULL)
+ return (spa->spa_dedup_dspace);
+
+ bzero(&dds_total, sizeof (ddt_stat_t));
+ /* Calculate and cache the stats */
ddt_get_dedup_stats(spa, &dds_total);
- return (dds_total.dds_ref_dsize - dds_total.dds_dsize);
+ spa->spa_dedup_dspace = dds_total.dds_ref_dsize - dds_total.dds_dsize;
+ return (spa->spa_dedup_dspace);
}
uint64_t
@@ -915,6 +922,7 @@ ddt_load(spa_t *spa)
*/
bcopy(ddt->ddt_histogram, &ddt->ddt_histogram_cache,
sizeof (ddt->ddt_histogram));
+ spa->spa_dedup_dspace = ~0ULL;
}
return (0);
@@ -1182,6 +1190,7 @@ ddt_sync_table(ddt_t *ddt, dmu_tx_t *tx, uint64_t txg)
bcopy(ddt->ddt_histogram, &ddt->ddt_histogram_cache,
sizeof (ddt->ddt_histogram));
+ spa->spa_dedup_dspace = ~0ULL;
}
void