Skip to content
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

btrfs-progs: refactor around btrfs_insert_file_extent() #919

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from

Commits on Nov 5, 2024

  1. btrfs-progs: do not call btrfs_record_file_extent() out of btrfs-convert

    The function btrfs_record_file_extent() has extra handling that's
    specific to convert, like allowing the range to be split by block group
    boundary and image file extent boundary.
    
    All of these split can only lead to corruption for non-converted fs.
    As the only caller out of btrfs-convert is rootdir, which expects the
    file extent item insert to respect the reserved data extent, and never
    to be split.
    
    Thankfully this is not going to cause huge problem, as
    btrfs_record_file_extent() has extra checks if the data extent overlaps
    with any existing one, and if it doesn't the handling will be the same
    as the kernel.
    
    But to avoid abuse, change btrfs_record_file_extent() by:
    
    - Rename it to btrfs_convert_file_extent()
      And add extra comments on that it is specific to btrfs-convert.
    
    - Move it to convert/common.[ch]
    
    - Introduce a helper insert_reserved_file_extent() for rootdir.c
    
    Signed-off-by: Qu Wenruo <[email protected]>
    adam900710 committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    ad7acbb View commit details
    Browse the repository at this point in the history
  2. btrfs-progs: make btrfs_insert_file_extent() to accept an on-stack fi…

    …le extent item
    
    Just like insert_reserved_file_extent() from the kernel, we can make
    btrfs_insert_file_extent() to accept an on-stack file extent item
    directly.
    
    This makes btrfs_insert_file_extent() more flex, and it can now handle
    the converted file extent where it has an non-zero offset.
    
    And this makes it much easier to expand for future compressed file
    extent generation.
    
    Signed-off-by: Qu Wenruo <[email protected]>
    adam900710 committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    4d5c932 View commit details
    Browse the repository at this point in the history