zfs icon indicating copy to clipboard operation
zfs copied to clipboard

Fast Dedup: Dedup Quota

Open allanjude opened this issue 1 year ago • 5 comments

Motivation and Context

Dedup tables can grow unbounded, which lets them consume an entire dedup vdev and so spill into the main pool, or grow too big to fit in RAM, hurting performance. This change adds options to allow the administrator to set a quota, which when reached will effectively disable dedup for new blocks.

Description

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 class. 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.

This replaces #10169

How Has This Been Tested?

Test added.

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Performance enhancement (non-breaking change which improves efficiency)
  • [ ] Code cleanup (non-breaking change which makes code smaller or more readable)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • [x] Documentation (a change to man pages or other documentation)

Checklist:

  • [x] My code follows the OpenZFS code style requirements.
  • [x] I have updated the documentation accordingly.
  • [x] I have read the contributing document.
  • [x] I have added tests to cover my changes.
  • [x] I have run the ZFS Test Suite with this change applied.
  • [x] All commit messages are properly formatted and contain Signed-off-by.

allanjude avatar Feb 14 '24 13:02 allanjude

Addressed review feedback and rebased to fix merge conflicts

don-brady avatar Apr 02 '24 22:04 don-brady

Fixed dedup quota test for Redhat distros

don-brady avatar Apr 18 '24 18:04 don-brady

rebased after zap shrinking was landed

don-brady avatar Apr 25 '24 02:04 don-brady

[Fast dedup stack rebased to master c98295eed]

robn avatar Jun 14 '24 01:06 robn

Last push just tightens up a number parse in the dedup_quota test a little, but no other changes.

robn avatar Jun 25 '24 01:06 robn

dedup_table_quota can be set to auto, which will set it based on the size of the devices backing the "dedup" allocation class.

I assume if you set it to auto and you don't have an alloc class device, then it doesn't place a limit on the DDT size (basically the old dedup behavior)?

If you have a special device but no dedup device, does auto set the DDT size to the special device size, since those can handle dedup allocations?

tonyhutter avatar Jul 11 '24 18:07 tonyhutter

dedup_table_quota can be set to auto, which will set it based on the size of the devices backing the "dedup" allocation class.

I assume if you set it to auto and you don't have an alloc class device, then it doesn't place a limit on the DDT size (basically the old dedup behavior)?

If you have a special device but no dedup device, does auto set the DDT size to the special device size, since those can handle dedup allocations?

If you set it to auto and have no dedup vdev, but do have a special vdev AND have zfs_ddt_data_is_special set (the default), then yes, it will use the special device size, respecting the same limits.

       /*
        * For automatic quota, table size is limited by dedup or special class
        */
       if (ddt_special_over_quota(spa, spa_dedup_class(spa)))
               return (B_TRUE);
       else if (spa_special_has_ddt(spa) &&
           ddt_special_over_quota(spa, spa_special_class(spa)))
               return (B_TRUE);

       return (B_FALSE);

allanjude avatar Jul 23 '24 13:07 allanjude

I haven't worked much with the dedup code, but I don't see any major issues.

tonyhutter avatar Jul 23 '24 22:07 tonyhutter

If you can fix the minor setup.ksh and cleanup.ksh stuff, then I think we can start wrapping this up.

tonyhutter avatar Jul 25 '24 00:07 tonyhutter