Leave zeros out of blank targets when reflinks are available - #439
Merged
Merged
Conversation
The null seed skipped zero ranges on a blank target, a new or truncated file, only when reflinks weren't available. With them, it cloned the zero block file into the target one filesystem block at a time, filling in holes that read as zeros already. On Btrfs, extracting a Debian 12 cloud image, 3.2 GB of which 2.2 GB are zeros, into a new file with the previous build as seed took 77s and left the file in 494k extents. Skipping the zeros, it takes 8.4s and leaves 6.7k extents, with the same result. With that, extracting into a new file with the old image as seed is the quickest way to update an image kept on a filesystem with reflinks, and the cookbook says so.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The null seed skips zero ranges on a blank target, a new or truncated file, but only when reflinks aren't available. With reflinks, it clones the zero block file into the target one filesystem block at a time, filling in holes that already read as zeros. On images with large zero-filled areas that's hundreds of thousands of clone calls, and just as many extents in the result.
This skips zeros on blank targets whether or not reflinks are available. The clone path only runs for targets that aren't blank anymore, so its handling of blank targets goes away.
The cookbook gains a note on the extraction example with seeds: on Btrfs and XFS, the new image shares what it has in common with the seed, zero-filled ranges stay holes, and extracting next to the old image is usually the fastest way to update one kept as a file.
Measured
Debian 12
genericcloudraw images, 3.2 GB of which about 2.2 GB are zeros, on Btrfs. The build from 2026-09-09 is extracted into a new file, with an older build as seed. The output is identical in all cases."New space" is what the file needs on top of the blocks it shares with the seed, from
btrfs filesystem du.