mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 03:37:45 +03:00
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:
@@ -3503,6 +3503,15 @@ zio_ddt_write(zio_t *zio)
|
||||
|
||||
ddt_enter(ddt);
|
||||
dde = ddt_lookup(ddt, bp, B_TRUE);
|
||||
if (dde == NULL) {
|
||||
/* DDT size is over its quota so no new entries */
|
||||
zp->zp_dedup = B_FALSE;
|
||||
BP_SET_DEDUP(bp, B_FALSE);
|
||||
if (zio->io_bp_override == NULL)
|
||||
zio->io_pipeline = ZIO_WRITE_PIPELINE;
|
||||
ddt_exit(ddt);
|
||||
return (zio);
|
||||
}
|
||||
ddp = &dde->dde_phys[p];
|
||||
|
||||
if (zp->zp_dedup_verify && zio_ddt_collision(zio, ddt, dde)) {
|
||||
@@ -3727,6 +3736,26 @@ zio_dva_allocate(zio_t *zio)
|
||||
* Fallback to normal class when an alloc class is full
|
||||
*/
|
||||
if (error == ENOSPC && mc != spa_normal_class(spa)) {
|
||||
/*
|
||||
* When the dedup or special class is spilling into the normal
|
||||
* class, there can still be significant space available due
|
||||
* to deferred frees that are in-flight. We track the txg when
|
||||
* this occurred and back off adding new DDT entries for a few
|
||||
* txgs to allow the free blocks to be processed.
|
||||
*/
|
||||
if ((mc == spa_dedup_class(spa) || (spa_special_has_ddt(spa) &&
|
||||
mc == spa_special_class(spa))) &&
|
||||
spa->spa_dedup_class_full_txg != zio->io_txg) {
|
||||
spa->spa_dedup_class_full_txg = zio->io_txg;
|
||||
zfs_dbgmsg("%s[%d]: %s class spilling, req size %d, "
|
||||
"%llu allocated of %llu",
|
||||
spa_name(spa), (int)zio->io_txg,
|
||||
mc == spa_dedup_class(spa) ? "dedup" : "special",
|
||||
(int)zio->io_size,
|
||||
(u_longlong_t)metaslab_class_get_alloc(mc),
|
||||
(u_longlong_t)metaslab_class_get_space(mc));
|
||||
}
|
||||
|
||||
/*
|
||||
* If throttling, transfer reservation over to normal class.
|
||||
* The io_allocator slot can remain the same even though we
|
||||
|
||||
Reference in New Issue
Block a user