Skip to content

Commit c57b38b

Browse files
rincebrainbehlendorf
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 #12271
1 parent d0c3d10 commit c57b38b

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
@@ -1797,8 +1797,22 @@ spa_get_worst_case_asize(spa_t *spa, uint64_t lsize)
17971797
uint64_t
17981798
spa_get_slop_space(spa_t *spa)
17991799
{
1800-
uint64_t space = spa_get_dspace(spa);
1801-
uint64_t slop = MIN(space >> spa_slop_shift, spa_max_slop);
1800+
uint64_t space = 0;
1801+
uint64_t slop = 0;
1802+
1803+
/*
1804+
* Make sure spa_dedup_dspace has been set.
1805+
*/
1806+
if (spa->spa_dedup_dspace == ~0ULL)
1807+
spa_update_dspace(spa);
1808+
1809+
/*
1810+
* spa_get_dspace() includes the space only logically "used" by
1811+
* deduplicated data, so since it's not useful to reserve more
1812+
* space with more deduplicated data, we subtract that out here.
1813+
*/
1814+
space = spa_get_dspace(spa) - spa->spa_dedup_dspace;
1815+
slop = MIN(space >> spa_slop_shift, spa_max_slop);
18021816

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

0 commit comments

Comments
 (0)