Skip to content

Commit 1325434

Browse files
authored
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 #12271
1 parent f7de776 commit 1325434

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
@@ -1786,8 +1786,22 @@ spa_get_worst_case_asize(spa_t *spa, uint64_t lsize)
17861786
uint64_t
17871787
spa_get_slop_space(spa_t *spa)
17881788
{
1789-
uint64_t space = spa_get_dspace(spa);
1790-
uint64_t slop = MIN(space >> spa_slop_shift, spa_max_slop);
1789+
uint64_t space = 0;
1790+
uint64_t slop = 0;
1791+
1792+
/*
1793+
* Make sure spa_dedup_dspace has been set.
1794+
*/
1795+
if (spa->spa_dedup_dspace == ~0ULL)
1796+
spa_update_dspace(spa);
1797+
1798+
/*
1799+
* spa_get_dspace() includes the space only logically "used" by
1800+
* deduplicated data, so since it's not useful to reserve more
1801+
* space with more deduplicated data, we subtract that out here.
1802+
*/
1803+
space = spa_get_dspace(spa) - spa->spa_dedup_dspace;
1804+
slop = MIN(space >> spa_slop_shift, spa_max_slop);
17911805

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

0 commit comments

Comments
 (0)