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
This commit is contained in:
parent
baf67d15a5
commit
e8a2014436
|
@ -239,6 +239,7 @@ struct spa {
|
||||||
uint64_t spa_autoexpand; /* lun expansion on/off */
|
uint64_t spa_autoexpand; /* lun expansion on/off */
|
||||||
ddt_t *spa_ddt[ZIO_CHECKSUM_FUNCTIONS]; /* in-core DDTs */
|
ddt_t *spa_ddt[ZIO_CHECKSUM_FUNCTIONS]; /* in-core DDTs */
|
||||||
uint64_t spa_ddt_stat_object; /* DDT statistics */
|
uint64_t spa_ddt_stat_object; /* DDT statistics */
|
||||||
|
uint64_t spa_dedup_dspace; /* Cache get_dedup_dspace() */
|
||||||
uint64_t spa_dedup_ditto; /* dedup ditto threshold */
|
uint64_t spa_dedup_ditto; /* dedup ditto threshold */
|
||||||
uint64_t spa_dedup_checksum; /* default dedup checksum */
|
uint64_t spa_dedup_checksum; /* default dedup checksum */
|
||||||
uint64_t spa_dspace; /* dspace in normal class */
|
uint64_t spa_dspace; /* dspace in normal class */
|
||||||
|
|
|
@ -529,10 +529,17 @@ ddt_get_dedup_stats(spa_t *spa, ddt_stat_t *dds_total)
|
||||||
uint64_t
|
uint64_t
|
||||||
ddt_get_dedup_dspace(spa_t *spa)
|
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);
|
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
|
uint64_t
|
||||||
|
@ -915,6 +922,7 @@ ddt_load(spa_t *spa)
|
||||||
*/
|
*/
|
||||||
bcopy(ddt->ddt_histogram, &ddt->ddt_histogram_cache,
|
bcopy(ddt->ddt_histogram, &ddt->ddt_histogram_cache,
|
||||||
sizeof (ddt->ddt_histogram));
|
sizeof (ddt->ddt_histogram));
|
||||||
|
spa->spa_dedup_dspace = ~0ULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
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,
|
bcopy(ddt->ddt_histogram, &ddt->ddt_histogram_cache,
|
||||||
sizeof (ddt->ddt_histogram));
|
sizeof (ddt->ddt_histogram));
|
||||||
|
spa->spa_dedup_dspace = ~0ULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -635,6 +635,9 @@ spa_add(const char *name, nvlist_t *config, const char *altroot)
|
||||||
spa->spa_min_ashift = INT_MAX;
|
spa->spa_min_ashift = INT_MAX;
|
||||||
spa->spa_max_ashift = 0;
|
spa->spa_max_ashift = 0;
|
||||||
|
|
||||||
|
/* Reset cached value */
|
||||||
|
spa->spa_dedup_dspace = ~0ULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As a pool is being created, treat all features as disabled by
|
* As a pool is being created, treat all features as disabled by
|
||||||
* setting SPA_FEATURE_DISABLED for all entries in the feature
|
* setting SPA_FEATURE_DISABLED for all entries in the feature
|
||||||
|
|
Loading…
Reference in New Issue