Skip to content

btrfs: extent-map: unify the members with btrfs_ordered_extent

Qu Wenruo linux-btrfs 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest11 patches 10 repliesIn review
  2. v211 patches 26 repliesSuperseded
  3. v18 patches 13 repliesSuperseded

Changes in v3 from the cover letter

- Rebased to the latest for-next
There is a small conflicts with the extent map tree members changes, no big deal.

- Fix an error where original code is checking btrfs_file_extent_disk_bytenr()
The newer code is checking disk_num_bytes, which is wrong.

- Various commit messages/comments update
Mostly some grammar fixes and removal of rants on the btrfs_file_extent member mismatches for btrfs_alloc_ordered_extent().
However a comment is still left inside btrfs_alloc_ordered_extent() for NOCOW/PREALLOC as a reminder for further cleanup.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11btrfs: rename extent_map::orig_block_len to disk_num_bytesfs/btrfs/extent_map.c fs/btrfs/extent_map.h fs/btrfs/file-item.c +3 more+20 -200 replies
2/11btrfs: export the expected file extent through can_nocow_extent()fs/btrfs/btrfs_inode.h fs/btrfs/file.c fs/btrfs/inode.c+36 -50 replies
3/11btrfs: introduce new members for extent_mapfs/btrfs/defrag.c fs/btrfs/extent_map.c fs/btrfs/extent_map.h +3 more+155 -114 replies
4/11btrfs: introduce extra sanity checks for extent mapsfs/btrfs/extent_map.c fs/btrfs/relocation.c fs/btrfs/tests/extent-map-tests.c +1 more+120 -21 reply
5/11btrfs: remove extent_map::orig_start memberfs/btrfs/btrfs_inode.h fs/btrfs/compression.c fs/btrfs/defrag.c +10 more+56 -1260 replies
6/11btrfs: remove extent_map::block_len memberfs/btrfs/compression.c fs/btrfs/extent_map.c fs/btrfs/extent_map.h +7 more+42 -1040 replies
7/11btrfs: remove extent_map::block_start memberfs/btrfs/compression.c fs/btrfs/defrag.c fs/btrfs/extent_io.c +11 more+168 -2062 replies
8/11btrfs: cleanup duplicated parameters related to can_nocow_file_extent_argsfs/btrfs/btrfs_inode.h fs/btrfs/file.c fs/btrfs/inode.c+38 -510 replies
9/11btrfs: cleanup duplicated parameters related to btrfs_alloc_ordered_extentfs/btrfs/btrfs_inode.h fs/btrfs/inode.c fs/btrfs/ordered-data.c +1 more+54 -691 reply
10/11btrfs: cleanup duplicated parameters related to create_io_em()fs/btrfs/inode.c+14 -410 replies
11/11btrfs: cleanup duplicated parameters related to btrfs_create_dio_extent()fs/btrfs/inode.c+7 -140 replies

Reviews trailers per patch

3 of 11 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchJohannes ThumshirnFilipe Manana
SeriesR-b R-b
1/11
2/11
3/11R-b
4/11R-b
5/11
6/11
7/11
8/11
9/11R-b
10/11
11/11

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 00/11] btrfs: extent-map: unify the members with btrfs_ordered_extent

[CHANGELOG]
v3:
- Rebased to the latest for-next
There is a small conflicts with the extent map tree members changes, no big deal.

- Fix an error where original code is checking btrfs_file_extent_disk_bytenr()
The newer code is checking disk_num_bytes, which is wrong.

- Various commit messages/comments update
Mostly some grammar fixes and removal of rants on the btrfs_file_extent member mismatches for btrfs_alloc_ordered_extent().
However a comment is still left inside btrfs_alloc_ordered_extent() for NOCOW/PREALLOC as a reminder for further cleanup.

v2:
- Rebased to the latest for-next
There is a conflicts with extent locking, and maybe some other hidden conflicts for NOCOW/PREALLOC?
As previously the patchset passes fstests auto group, but after the merging with other patches, it always crashes as btrfs/060.

- Fix an error in the final cleanup patch
It's the NOCOW/PREALLOC shenanigans again, in the buffered NOCOW path, that we have to use the old inaccurate numbers for NOCOW/PREALLOC OEs.

- Split the final cleanup into 4 patches
Most cleanups are very straightforward, but the cleanup for btrfs_alloc_ordered_extent() needs extra special handling for NOCOW/PREALLOC.

v1:
- Rebased to the latest for-next
To resolve the conflicts with the recently introduced extent map shrinker

- A new cleanup patch to remove the recursive header inclusion

- Use a new structure to pass the file extent item related members around

- Add a new comment on why we're intentionally passing incorrect numbers for NOCOW/PREALLOC ordered extents inside btrfs_create_dio_extent()

[REPO]
https://github.com/adam900710/linux/tree/em_cleanup

This series introduce two new members (disk_bytenr/offset) to extent_map, and removes three old members (block_start/block_len/offset), finally rename one member (orig_block_len -> disk_num_bytes).

This should save us one u64 for extent_map, although with the recent extent map shrinker, the saving is not that useful.

But to make things safe to migrate, I introduce extra sanity checks for extent_map, and do cross check for both old and new members.

The extra sanity checks already exposed one bug (thankfully harmless) causing em::block_start to be incorrect.

But so far, the patchset is fine for default fstests run.

Furthermore, since we're already having too long parameter lists for extent_map/ordered_extent/can_nocow_extent, here is a new structure, btrfs_file_extent, a memory-access-friendly structure to represent a btrfs_file_extent_item.

With the help of that structure, we can use that to represent a file extent item without a super long parameter list.

The patchset would rename orig_block_len to disk_num_bytes first. Then introduce the new member, the extra sanity checks, and introduce the new btrfs_file_extent structure and use that to remove the older 3 members from extent_map.

After all above works done, use btrfs_file_extent to further cleanup can_nocow_file_extent_args()/btrfs_alloc_ordered_extent()/create_io_em()/ btrfs_create_dio_extent().

The cleanup is in fact pretty tricky, the current code base never expects correct numbers for NOCOW/PREALLOC OEs, thus we have to keep the old but incorrect numbers just for NOCOW/PREALLOC.

I will address the NOCOW/PREALLOC shenanigans the future, but after the huge cleanup across multiple core structures.

Qu Wenruo (11):
btrfs: rename extent_map::orig_block_len to disk_num_bytes
btrfs: export the expected file extent through can_nocow_extent()
btrfs: introduce new members for extent_map
btrfs: introduce extra sanity checks for extent maps
btrfs: remove extent_map::orig_start member
btrfs: remove extent_map::block_len member
btrfs: remove extent_map::block_start member
btrfs: cleanup duplicated parameters related to
can_nocow_file_extent_args
btrfs: cleanup duplicated parameters related to
btrfs_alloc_ordered_extent
btrfs: cleanup duplicated parameters related to create_io_em()
btrfs: cleanup duplicated parameters related to
btrfs_create_dio_extent()

 fs/btrfs/btrfs_inode.h            |   4 +-
 fs/btrfs/compression.c            |   7 +-
 fs/btrfs/defrag.c                 |  14 +-
 fs/btrfs/extent_io.c              |  10 +-
 fs/btrfs/extent_map.c             | 192 +++++++++++++------
 fs/btrfs/extent_map.h             |  51 +++--
 fs/btrfs/file-item.c              |  23 +--
 fs/btrfs/file.c                   |  18 +-
 fs/btrfs/inode.c                  | 308 +++++++++++++-----------------
 fs/btrfs/ordered-data.c           |  34 +++-
 fs/btrfs/ordered-data.h           |  19 +-
 fs/btrfs/relocation.c             |   5 +-
 fs/btrfs/tests/extent-map-tests.c | 114 ++++++-----
 fs/btrfs/tests/inode-tests.c      | 177 ++++++++---------
 fs/btrfs/tree-log.c               |  23 ++-
 fs/btrfs/zoned.c                  |   4 +-
 include/trace/events/btrfs.h      |  18 +-
 17 files changed, 541 insertions(+), 480 deletions(-)
Signature · 1 line
2.45.1