btrfs-progs: refactor around btrfs_insert_file_extent() #919
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.
Although btrfs_insert_file_extent() is a btrfs-progs specific function,
it's pretty close (although not yet similiar enough to cross-port) to
insert_reserved_file_extent() from kernel.
That kernel function uses an on-stack btrfs_file_extent_item to pass all
the needed parameters, supporting both compressed and uncompressed data
extents.
That is way more flex than btrfs_insert_file_extent() from btrfs-progs,
which can not support:
To prepare for the incoming support of compressed data extents
generation for mkfs --rootdir, we need a more generic way to insert file
extents.
This patch improve the situation by:
Move btrfs_record_file_extent() to be a convert specific function
The extra handling are all for converted btrfs, and can split extents
where regular btrfs doesn't want.
For mkfs/rootdir.c, the only caller out of convert, introduce a
helper, insert_reserved_file_extent() to handle the case.
Make btrfs_insert_file_extent() to accept an on-stack btrfs_file_extent_item
Just like insert_reserved_file_extent() from kernel.
Allowing us to customize ever member of the btrfs_file_extent_item.
Now this makes btrfs_insert_file_extent() flex enough for converted
fs, and the incoming compressed file extents.