Skip to content

Commit f953224

Browse files
rincebraindatacore-rm
authored andcommitted
Tinker with slop space accounting with dedup
* Tinker with slop space accounting with dedup Do not include the deduplicated space usage in the slop space reservation, it leads to surprising outcomes. * Update spa_dedup_dspace sometimes Sometimes, we get into spa_get_slop_space() with spa_dedup_dspace=~0ULL, AKA "unset", while spa_dspace is correctly set. So call the code to update it before we use it if we hit that case. Reviewed-by: Matthew Ahrens <[email protected]> Reviewed-by: Mark Maybee <[email protected]> Signed-off-by: Rich Ercolani <[email protected]> Closes openzfs#12271
1 parent 177e007 commit f953224

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

module/zfs/ddt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ ddt_get_dedup_histogram(spa_t *spa, ddt_histogram_t *ddh)
503503
{
504504
for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) {
505505
ddt_t *ddt = spa->spa_ddt[c];
506-
for (enum ddt_type type = 0; type < DDT_TYPES; type++) {
506+
for (enum ddt_type type = 0; type < DDT_TYPES && ddt; type++) {
507507
for (enum ddt_class class = 0; class < DDT_CLASSES;
508508
class++) {
509509
ddt_histogram_add(ddh,

module/zfs/spa_misc.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,8 +1802,22 @@ spa_get_worst_case_asize(spa_t *spa, uint64_t lsize)
18021802
uint64_t
18031803
spa_get_slop_space(spa_t *spa)
18041804
{
1805-
uint64_t space = spa_get_dspace(spa);
1806-
uint64_t slop = MIN(space >> spa_slop_shift, spa_max_slop);
1805+
uint64_t space = 0;
1806+
uint64_t slop = 0;
1807+
1808+
/*
1809+
* Make sure spa_dedup_dspace has been set.
1810+
*/
1811+
if (spa->spa_dedup_dspace == ~0ULL)
1812+
spa_update_dspace(spa);
1813+
1814+
/*
1815+
* spa_get_dspace() includes the space only logically "used" by
1816+
* deduplicated data, so since it's not useful to reserve more
1817+
* space with more deduplicated data, we subtract that out here.
1818+
*/
1819+
space = spa_get_dspace(spa) - spa->spa_dedup_dspace;
1820+
slop = MIN(space >> spa_slop_shift, spa_max_slop);
18071821

18081822
/*
18091823
* Subtract the embedded log space, but no more than half the (3.2%)

0 commit comments

Comments
 (0)