public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs-progs: refactor around btrfs_insert_file_extent()
@ 2024-11-05  6:48 Qu Wenruo
  2024-11-05  6:48 ` [PATCH 1/2] btrfs-progs: do not call btrfs_record_file_extent() out of btrfs-convert Qu Wenruo
  2024-11-05  6:48 ` [PATCH 2/2] btrfs-progs: make btrfs_insert_file_extent() to accept an on-stack file extent item Qu Wenruo
  0 siblings, 2 replies; 3+ messages in thread
From: Qu Wenruo @ 2024-11-05  6:48 UTC (permalink / raw)
  To: linux-btrfs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-05  6:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-05  6:48 [PATCH 0/2] btrfs-progs: refactor around btrfs_insert_file_extent() Qu Wenruo
2024-11-05  6:48 ` [PATCH 1/2] btrfs-progs: do not call btrfs_record_file_extent() out of btrfs-convert Qu Wenruo
2024-11-05  6:48 ` [PATCH 2/2] btrfs-progs: make btrfs_insert_file_extent() to accept an on-stack file extent item Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox