Feature #13916
openZAP should support shrinking
90%
Description
ZFS ZAP can expand, but cannot shrink. This change makes ZAP capable to shrink.
Algorithm is kinda opposite to that how ZAP is expanding. While expanding, a leaf is split on two (siblings).
While shrinking, if we got an empty leaf and it has a sibling and the sibling leaf is empty as well, we remove one of them. The remaining leaf is empty and might have a sibling again. So, we repeat the procedure until there is no sibling or the sibling is not empty.
To clarify: the sibling leaves are those ones, which have same prefix_len and their prefix differs only by least significant bit (sibling bit).
Updated by Alexander Stetsenko almost 2 years ago
- Description updated (diff)
Alexander Stetsenko wrote:
ZFS ZAP can expand, but cannot shrink. This change makes ZAP capable to shrink.
Algorithm is kinda opposite to that how ZAP is expanding. While expanding, a leaf is split on two (siblings).
While shrinking, if we got an empty leaf and it has a sibling and the sibling leaf is empty as well, we remove one of them. The remaining leaf is empty and might have a sibling again. So, we repeat the procedure until there is no sibling or the sibling is not empty.