ddt: dedup table quota enforcement

This adds two new pool properties:
- dedup_table_size, the total size of all DDTs on the pool; and
- dedup_table_quota, the maximum possible size of all DDTs in the pool

When set, quota will be enforced by checking when a new entry is about
to be created. If the pool is over its dedup quota, the entry won't be
created, and the corresponding write will be converted to a regular
non-dedup write. Note that existing entries can be updated (ie their
refcounts changed), as that reuses the space rather than requiring more.

dedup_table_quota can be set to 'auto', which will set it based on the
size of the devices backing the "dedup" allocation device. This makes it
possible to limit the DDTs to the size of a dedup vdev only, such that
when the device fills, no new blocks are deduplicated.

Sponsored-by: iXsystems, Inc.
Sponsored-By: Klara Inc.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Signed-off-by: Don Brady <don.brady@klarasystems.com>
Co-authored-by: Don Brady <don.brady@klarasystems.com>
Co-authored-by: Rob Wing <rob.wing@klarasystems.com>
Co-authored-by: Sean Eric Fagan <sean.fagan@klarasystems.com>
Closes #15889
This commit is contained in:
Allan Jude
2024-07-25 12:47:36 -04:00
committed by GitHub
parent 82f281ad99
commit c7ada64bb6
22 changed files with 599 additions and 22 deletions
+44 -6
View File
@@ -129,7 +129,8 @@ ddt_histogram_empty(const ddt_histogram_t *ddh)
void
ddt_get_dedup_object_stats(spa_t *spa, ddt_object_t *ddo_total)
{
/* Sum the statistics we cached in ddt_object_sync(). */
memset(ddo_total, 0, sizeof (*ddo_total));
for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) {
ddt_t *ddt = spa->spa_ddt[c];
if (!ddt)
@@ -138,8 +139,32 @@ ddt_get_dedup_object_stats(spa_t *spa, ddt_object_t *ddo_total)
for (ddt_type_t type = 0; type < DDT_TYPES; type++) {
for (ddt_class_t class = 0; class < DDT_CLASSES;
class++) {
dmu_object_info_t doi;
uint64_t cnt;
int err;
/*
* These stats were originally calculated
* during ddt_object_load().
*/
err = ddt_object_info(ddt, type, class, &doi);
if (err != 0)
continue;
err = ddt_object_count(ddt, type, class, &cnt);
if (err != 0)
continue;
ddt_object_t *ddo =
&ddt->ddt_object_stats[type][class];
ddo->ddo_count = cnt;
ddo->ddo_dspace =
doi.doi_physical_blocks_512 << 9;
ddo->ddo_mspace = doi.doi_fill_count *
doi.doi_data_block_size;
ddo_total->ddo_count += ddo->ddo_count;
ddo_total->ddo_dspace += ddo->ddo_dspace;
ddo_total->ddo_mspace += ddo->ddo_mspace;
@@ -147,11 +172,24 @@ ddt_get_dedup_object_stats(spa_t *spa, ddt_object_t *ddo_total)
}
}
/* ... and compute the averages. */
if (ddo_total->ddo_count != 0) {
ddo_total->ddo_dspace /= ddo_total->ddo_count;
ddo_total->ddo_mspace /= ddo_total->ddo_count;
}
/*
* This returns raw counts (not averages). One of the consumers,
* print_dedup_stats(), historically has expected raw counts.
*/
spa->spa_dedup_dsize = ddo_total->ddo_dspace;
}
uint64_t
ddt_get_ddt_dsize(spa_t *spa)
{
ddt_object_t ddo_total;
/* recalculate after each txg sync */
if (spa->spa_dedup_dsize == ~0ULL)
ddt_get_dedup_object_stats(spa, &ddo_total);
return (spa->spa_dedup_dsize);
}
void