mbox series

[0/2] btrfs-progs: refactor around btrfs_insert_file_extent()

Message ID cover.1730788965.git.wqu@suse.com (mailing list archive)
Headers show
Series btrfs-progs: refactor around btrfs_insert_file_extent() | expand

Message

Qu Wenruo Nov. 5, 2024, 6:48 a.m. UTC
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:

- Non-zero offset
- Ram_bytes larger than num_bytes
- Compressed extents

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.

Qu Wenruo (2):
  btrfs-progs: do not call btrfs_record_file_extent() out of
    btrfs-convert
  btrfs-progs: make btrfs_insert_file_extent() to accept an on-stack
    file extent item

 common/extent-tree-utils.c | 240 -------------------------------------
 common/extent-tree-utils.h |   5 -
 convert/common.c           | 237 +++++++++++++++++++++++++++++++++++-
 convert/common.h           |   6 +
 convert/main.c             |  10 +-
 convert/source-fs.c        |   4 +-
 convert/source-reiserfs.c  |   2 +-
 kernel-shared/file-item.c  |  44 ++-----
 kernel-shared/file-item.h  |   4 +-
 kernel-shared/file.c       |   6 +-
 mkfs/rootdir.c             | 104 +++++++++++++++-
 11 files changed, 369 insertions(+), 293 deletions(-)

--
2.47.0