-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fast Dedup: ZAP Shrinking #15888
Fast Dedup: ZAP Shrinking #15888
Conversation
a076382
to
b9c2849
Compare
module/zfs/zap.c
Outdated
uint64_t sl_hash = ZAP_PREFIX_HASH(sl_prefix, prefix_len); | ||
int slbit = prefix & 1; | ||
|
||
ASSERT3U(zt_shift, ==, zap_f_phys(zap)->zap_ptrtbl.zt_shift); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should re-read zt_shift from ZAP after reacquiring the ZAP lock below, where it may actually change, instead of asserting this here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
I'm extremely happy to see this one getting attention! This has been one of my 'pet bugs' for years. |
module/zfs/zap.c
Outdated
uint64_t sl_hash = ZAP_PREFIX_HASH(sl_prefix, prefix_len); | ||
int slbit = prefix & 1; | ||
|
||
ASSERT3S(zap_leaf_phys(l)->l_hdr.lh_nentries, ==, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ASSERT3S(zap_leaf_phys(l)->l_hdr.lh_nentries, ==, 0); | |
ASSERT3U(zap_leaf_phys(l)->l_hdr.lh_nentries, ==, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As part of this commit let's add explicit test coverage for at least one of the most common cases. Specifically creating a directory, adding a large number of files so it's converted to a fatzap, then removing those files and verifying the zap is collapsed.
The tests/zfs-tests/tests/functional/cp_files/cp_files_001_pos.ksh
already does most of this and would be relatively easy to extend by using zdb
check the zap stats.
Can you also add your signed off by when refreshing this.
This allows ZAPs to shrink. When there are two empty sibling leafs, one of them is collapsed and its storage space is reused. This improved performance on directories that at one time contained a large number of files, but many or all of those files have since been deleted. This also applies to all other types of ZAPs as well. Sponsored-by: iXsystems, Inc. Sponsored-by: Klara, Inc. Signed-off-by: Alexander Stetsenko <alex.stetsenko@klarasystems.com>
Sponsored-by: iXsystems, Inc. Sponsored-by: Klara, Inc. Signed-off-by: Alexander Stetsenko <alex.stetsenko@klarasystems.com>
fcd91d5
to
2599b25
Compare
tests/zfs-tests/tests/functional/zap_shrink/zap_shrink_001_pos.ksh
Outdated
Show resolved
Hide resolved
tests/zfs-tests/tests/functional/zap_shrink/zap_shrink_001_pos.ksh
Outdated
Show resolved
Hide resolved
tests/zfs-tests/tests/functional/zap_shrink/zap_shrink_001_pos.ksh
Outdated
Show resolved
Hide resolved
tests/zfs-tests/tests/functional/zap_shrink/zap_shrink_001_pos.ksh
Outdated
Show resolved
Hide resolved
a22f7d1
to
1c3c09a
Compare
tests/zfs-tests/tests/functional/zap_shrink/zap_shrink_001_pos.ksh
Outdated
Show resolved
Hide resolved
Sponsored-by: iXsystems, Inc. Sponsored-by: Klara, Inc. Signed-off-by: Alexander Stetsenko <alex.stetsenko@klarasystems.com>
1c3c09a
to
297a274
Compare
Awesome that this got merged! Thanks to klarasystems & iX! @behlendorf It is possible that this can be backported and released in a 2.2.x release, independent from the whole/complete fast dedupe feature? |
@jumbi77 yes, but we'll want it to have had a lot of soak time in the master branch first. |
May i ask if around 4 month is enough soak time? @tonyhutter is it possible to pull this into current 2.2.6? |
This allows ZAPs to shrink. When there are two empty sibling leafs, one of them is collapsed and its storage space is reused. This improved performance on directories that at one time contained a large number of files, but many or all of those files have since been deleted. This also applies to all other types of ZAPs as well. Sponsored-by: iXsystems, Inc. Sponsored-by: Klara, Inc. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Alexander Stetsenko <alex.stetsenko@klarasystems.com> Closes openzfs#15888
Motivation and Context
If ZAP records are deleted such that an entire leaf block of the ZAP object is emptied, the block is not reclaimed.
In addition to allowing directories and other users of ZAPs to shrink when a large number of objects are removed, this is required for Fast Dedup's DDT pruning feature.
Description
This change addresses this issue in part by noticing when adjacent blocks are emptied, and collapses them into a single empty block, thereby reducing the total amount of space in the ZAP object.
This adds a tuneable,
zfs_zap_shrink_enabled
, set by default. If disabled, the shrinking behaviour is disabled.This replaces #14088
How Has This Been Tested?
TBD.
Types of changes
Checklist:
Signed-off-by
.