Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs: more explaination on extent_map members
@ 2024-04-02  6:23 Qu Wenruo
  2024-04-02  6:23 ` [PATCH 1/2] btrfs: add extra comments " Qu Wenruo
  2024-04-02  6:23 ` [PATCH 2/2] btrfs: simplify the inline extent map creation Qu Wenruo
  0 siblings, 2 replies; 7+ messages in thread
From: Qu Wenruo @ 2024-04-02  6:23 UTC (permalink / raw)
  To: linux-btrfs

Btrfs uses extent_map to represent a in-memory file extent.

There are severam members that are 1:1 mappe in on-disk file extent
items and extent maps:

- extent_map::start	==	key.offset
- extent_map::len	==	file_extent_num_bytes
- extent_map::ram_bytes	==	file_extent_ram_bytes

But that's all, the remaining are pretty different:

- Use block_start to indicate holes/inline extents
  Meanwhile btrfs on-disk file extent items go with a dedicated type for
  inline extents, and disk_bytenr 0 for holes.

- Extra members for fsync optimization
  I'm still not 100% sure how mod_start and mod_len really works though.

- Weird block_start/orig_block_len/orig_start
  In theory we can directly go with the same file_extent_disk_bytenr,
  file_extent_disk_num_bytes and file_extent_offset to calculate the
  remaining members (block_start/orig_start/orig_block_len/block_len).

  But for whatever reason, we didn't go that path and have a hell of
  weird and inconsistent calculation for them.

I do not have the confidence to handle the mess yet, but as the first
step, I would add comments for those members mostly according to
btrfs_extent_item_to_extent_map(), and hopefully we can improve the
situation in not-far-away future.

Qu Wenruo (2):
  btrfs: add extra comments on extent_map members
  btrfs: simplify the inline extent map creation

 fs/btrfs/extent_map.h | 62 ++++++++++++++++++++++++++++++++++++++++++-
 fs/btrfs/file-item.c  | 14 ++++++----
 2 files changed, 70 insertions(+), 6 deletions(-)

-- 
2.44.0


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

end of thread, other threads:[~2024-04-02 15:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-02  6:23 [PATCH 0/2] btrfs: more explaination on extent_map members Qu Wenruo
2024-04-02  6:23 ` [PATCH 1/2] btrfs: add extra comments " Qu Wenruo
2024-04-02  7:33   ` Andrea Gelmini
2024-04-02  8:25     ` Qu Wenruo
2024-04-02 15:45   ` Filipe Manana
2024-04-02  6:23 ` [PATCH 2/2] btrfs: simplify the inline extent map creation Qu Wenruo
2024-04-02 15:50   ` Filipe Manana

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