Skip to content

btrfs: move extent_io_tree code and cleanups

Josef Bacik linux-btrfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest36 patches 9 repliesIn review
  2. v131 patches 9 repliesSuperseded

Changes in v2 from the cover letter

- Addressed the comments.
- Broke up the giant move code patch up a bit by adding more exports and moving other things in chunks. There's still a big code move patch, but it's 1000 lines shorter, and not possible to shrink more without renaming functions.
- Fixed a problem that crept in from rebasing previously.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/36btrfs: rename clean_io_failure and remove extraneous argsfs/btrfs/compression.c fs/btrfs/extent-io-tree.h fs/btrfs/extent_io.c +1 more+13 -225 replies
2/36btrfs: unexport internal failrec functionsfs/btrfs/extent-io-tree.h fs/btrfs/extent_io.c+7 -122 replies
3/36btrfs: convert the io_failure_tree to a plain rb_treefs/btrfs/btrfs_inode.h fs/btrfs/extent-io-tree.h fs/btrfs/extent_io.c +4 more+96 -1201 reply
4/36btrfs: use find_first_extent_bit in btrfs_clean_io_failurefs/btrfs/extent_io.c+6 -90 replies
5/36btrfs: separate out the extent state and extent buffer init codefs/btrfs/extent-io-tree.h fs/btrfs/extent_io.c fs/btrfs/extent_io.h +1 more+31 -140 replies
6/36btrfs: separate out the eb and extent state leak helpersfs/btrfs/extent_io.c+38 -200 replies
7/36btrfs: temporarily export alloc_extent_state helpersfs/btrfs/extent-io-tree.h fs/btrfs/extent_io.c+5 -30 replies
8/36btrfs: move extent state init and alloc functions to their own filefs/btrfs/Makefile fs/btrfs/extent-io-tree.c fs/btrfs/extent-io-tree.h +1 more+166 -1560 replies
9/36btrfs: convert BUG_ON(EXTENT_BIT_LOCKED) checks to ASSERT'sfs/btrfs/extent_io.c+2 -20 replies
10/36btrfs: move simple extent bit helpers out of extent_io.cfs/btrfs/extent-io-tree.c fs/btrfs/extent-io-tree.h fs/btrfs/extent_io.c+60 -650 replies
11/36btrfs: export wait_extent_bitfs/btrfs/extent-io-tree.h fs/btrfs/extent_io.c+2 -20 replies
12/36btrfs: move btrfs_debug_check_extent_io_range into extent-io-tree.cfs/btrfs/extent-io-tree.c fs/btrfs/extent-io-tree.h fs/btrfs/extent_io.c+29 -200 replies
13/36btrfs: temporarily export and move core extent_io_tree tree functionsfs/btrfs/extent-io-tree.c fs/btrfs/extent-io-tree.h fs/btrfs/extent_io.c+120 -1150 replies
14/36btrfs: temporarily export and then move extent state helpersfs/btrfs/extent-io-tree.c fs/btrfs/extent-io-tree.h fs/btrfs/extent_io.c+267 -2580 replies
15/36btrfs: move a few exported extent_io_tree helpers to extent-io-tree.cfs/btrfs/extent-io-tree.c fs/btrfs/extent_io.c+142 -1410 replies
16/36btrfs: move core extent_io_tree functions to extent-io-tree.cfs/btrfs/extent-io-tree.c fs/btrfs/extent_io.c+996 -9960 replies
17/36btrfs: unexport btrfs_debug_check_extent_io_rangefs/btrfs/extent-io-tree.c fs/btrfs/extent-io-tree.h+6 -130 replies
18/36btrfs: unexport all the temporary exports for extent-io-tree.cfs/btrfs/extent-io-tree.c fs/btrfs/extent-io-tree.h+47 -690 replies
19/36btrfs: remove struct tree_entryfs/btrfs/extent-io-tree.c+12 -120 replies
20/36btrfs: use next_state instead of rb_next where we canfs/btrfs/extent-io-tree.c+24 -330 replies
21/36btrfs: make tree_search return struct extent_statefs/btrfs/extent-io-tree.c+14 -370 replies
22/36btrfs: make tree_search_for_insert return extent_statefs/btrfs/extent-io-tree.c+16 -270 replies
23/36btrfs: make tree_search_prev_next return extent_state'sfs/btrfs/extent-io-tree.c+38 -420 replies
24/36btrfs: use next_state/prev_state in merge_statefs/btrfs/extent-io-tree.c+20 -290 replies
25/36btrfs: move irrelevant prototypes to their appropriate headerfs/btrfs/extent-io-tree.h fs/btrfs/extent_io.h+6 -80 replies
26/36btrfs: drop exclusive_bits from set_extent_bitfs/btrfs/extent-io-tree.c fs/btrfs/extent-io-tree.h fs/btrfs/inode.c+20 -190 replies
27/36btrfs: remove the wake argument from clear_extent_bitsfs/btrfs/extent-io-tree.c fs/btrfs/extent-io-tree.h fs/btrfs/extent_io.c +9 more+41 -470 replies
28/36btrfs: remove failed_start argument from set_extent_bitfs/btrfs/extent-io-tree.c fs/btrfs/extent-io-tree.h fs/btrfs/inode.c+30 -260 replies
29/36btrfs: drop extent_changeset from set_extent_bitfs/btrfs/extent-io-tree.c fs/btrfs/extent-io-tree.h fs/btrfs/inode.c+12 -150 replies
30/36btrfs: unify the lock/unlock extent variantsfs/btrfs/compression.c fs/btrfs/disk-io.c fs/btrfs/extent-io-tree.c +11 more+142 -1620 replies
31/36btrfs: remove extent_io_tree::track_uptodatefs/btrfs/disk-io.c fs/btrfs/extent-io-tree.h fs/btrfs/inode.c+0 -30 replies
32/36btrfs: get rid of extent_io_tree::dirty_bytesfs/btrfs/extent-io-tree.c fs/btrfs/extent-io-tree.h+1 -170 replies
33/36btrfs: don't clear CTL bits when trying to release extent statefs/btrfs/extent_io.c+5 -30 replies
34/36btrfs: replace delete argument with EXTENT_CLEAR_ALL_BITSfs/btrfs/extent-io-tree.c fs/btrfs/extent-io-tree.h fs/btrfs/extent_io.c +9 more+61 -550 replies
35/36btrfs: don't init io tree with private data for non inodesfs/btrfs/disk-io.c fs/btrfs/inode.c fs/btrfs/transaction.c+3 -30 replies
36/36btrfs: remove is_data_inode() checks in extent-io-tree.cfs/btrfs/extent-io-tree.c+6 -60 replies

Reviews trailers per patch

2 of 36 patches have a Reviewed-by or Acked-by.

PatchJohannes Thumshirn
1/36R-b
2/36R-b
3/36
4/36
5/36
6/36
7/36
8/36
9/36
10/36
11/36
12/36
13/36
14/36
15/36
16/36
17/36
18/36
19/36
20/36
21/36
22/36
23/36
24/36
25/36
26/36
27/36
28/36
29/36
30/36
31/36
32/36
33/36
34/36
35/36
36/36

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

Read the v2 thread

Cover letter [PATCH v2 00/36] btrfs: move extent_io_tree code and cleanups

v1->v2:
- Addressed the comments.
- Broke up the giant move code patch up a bit by adding more exports and moving other things in chunks. There's still a big code move patch, but it's 1000 lines shorter, and not possible to shrink more without renaming functions.
- Fixed a problem that crept in from rebasing previously.

--- Original email ---
Hello,

In working on extent tree v2 I got really bogged down in trying to sync work between btrfs-progs and the kernel. It basically takes me 3x as long, because there's a lot of different things missing in btrfs-progs, so each patchset has to be done from scratch and tested completely differently.

Additionally there's just a lot of tech-debt in these areas in general. So before tackling the rest of extent-tree-v2 I'm spending some time cleaning up things we all know are terrible. This is the first step in that direction, finishing the separation of the extent_io_tree code from extent_io.c. I started this a while ago, but got bogged down in other things.

This has 3 distinct parts

1. Cleanup the io_failure_record code. This has been tightly integrated into the extent_io_tree code forever without much reason for it. The first part of this series moves that handling into it's own tree, and uses our existing helpers to reduce the code quite a bit.

2. Move the code out of extent_io.c. This is easier than previous code moves because I did a lot of the prep work earlier. Unfortunately there is one big patch that copy and pastes all the core code, since it all depends on itself and would be more annoying to move. However the independent parts were moved piece by piece.

3. A wholesale cleanup of the extent_io_tree code. We have a ton of helpers here, that have all grown a ton of arguments over the years. I've trimmed down the arguments for our core helpers, and hidden the rest internally inside of extent-io-tree.c. Additionally I've cleaned up the lock/unlock extent bit helpers so we only have one lock_extent/unlock_extent variant that gets used everywhere.

I've tested this locally to make sure I didn't break anything. This isn't a simple code move so do please review most of it, the patches that start with "move X" are pure code move patches, but the rest do change things. Thanks,

Josef

Josef Bacik (36):
btrfs: rename clean_io_failure and remove extraneous args
btrfs: unexport internal failrec functions
btrfs: convert the io_failure_tree to a plain rb_tree
btrfs: use find_first_extent_bit in btrfs_clean_io_failure
btrfs: separate out the extent state and extent buffer init code
btrfs: separate out the eb and extent state leak helpers
btrfs: temporarily export alloc_extent_state helpers
btrfs: move extent state init and alloc functions to their own file
btrfs: convert BUG_ON(EXTENT_BIT_LOCKED) checks to ASSERT's
btrfs: move simple extent bit helpers out of extent_io.c
btrfs: export wait_extent_bit
btrfs: move btrfs_debug_check_extent_io_range into extent-io-tree.c
btrfs: temporarily export and move core extent_io_tree tree functions
btrfs: temporarily export and then move extent state helpers
btrfs: move a few exported extent_io_tree helpers to extent-io-tree.c
btrfs: move core extent_io_tree functions to extent-io-tree.c
btrfs: unexport btrfs_debug_check_extent_io_range
btrfs: unexport all the temporary exports for extent-io-tree.c
btrfs: remove struct tree_entry
btrfs: use next_state instead of rb_next where we can
btrfs: make tree_search return struct extent_state
btrfs: make tree_search_for_insert return extent_state
btrfs: make tree_search_prev_next return extent_state's
btrfs: use next_state/prev_state in merge_state
btrfs: move irrelevant prototypes to their appropriate header
btrfs: drop exclusive_bits from set_extent_bit
btrfs: remove the wake argument from clear_extent_bits
btrfs: remove failed_start argument from set_extent_bit
btrfs: drop extent_changeset from set_extent_bit
btrfs: unify the lock/unlock extent variants
btrfs: remove extent_io_tree::track_uptodate
btrfs: get rid of extent_io_tree::dirty_bytes
btrfs: don't clear CTL bits when trying to release extent state
btrfs: replace delete argument with EXTENT_CLEAR_ALL_BITS
btrfs: don't init io tree with private data for non inodes
btrfs: remove is_data_inode() checks in extent-io-tree.c

 fs/btrfs/Makefile                |    2 +-
 fs/btrfs/btrfs_inode.h           |    3 +-
 fs/btrfs/compression.c           |   11 +-
 fs/btrfs/disk-io.c               |   10 +-
 fs/btrfs/extent-io-tree.c        | 1678 ++++++++++++++++++++++++
 fs/btrfs/extent-io-tree.h        |  119 +-
 fs/btrfs/extent_io.c             | 2054 ++----------------------------
 fs/btrfs/extent_io.h             |   14 +-
 fs/btrfs/extent_map.c            |    2 +-
 fs/btrfs/file-item.c             |    2 +-
 fs/btrfs/file.c                  |   48 +-
 fs/btrfs/free-space-cache.c      |   24 +-
 fs/btrfs/inode.c                 |  159 ++-
 fs/btrfs/ioctl.c                 |   24 +-
 fs/btrfs/misc.h                  |   35 +
 fs/btrfs/ordered-data.c          |    4 +-
 fs/btrfs/reflink.c               |   10 +-
 fs/btrfs/relocation.c            |   18 +-
 fs/btrfs/super.c                 |   17 +-
 fs/btrfs/tests/extent-io-tests.c |    6 +-
 fs/btrfs/tests/inode-tests.c     |    8 +-
 fs/btrfs/transaction.c           |    4 +-
 fs/btrfs/tree-log.c              |    8 +-
 include/trace/events/btrfs.h     |    1 -
 24 files changed, 2082 insertions(+), 2179 deletions(-)
 create mode 100644 fs/btrfs/extent-io-tree.c
Signature · 1 line
2.26.3