Skip to content

btrfs: simplify use of struct btrfs_root pointers

[email protected] linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest28 of 31 patches 15 repliesIn review

28 of 31 patches are in this archive. The cover letter announces 31.

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/31btrfs: plumb fs_info into btrfs_workfs/btrfs/async-thread.c fs/btrfs/async-thread.h fs/btrfs/disk-io.c +1 more+63 -310 replies
2/31btrfs: prefix fsid to all trace eventsfs/btrfs/delayed-ref.c fs/btrfs/extent-tree.c fs/btrfs/qgroup.c +3 more+182 -1491 reply
3/31btrfs: btrfs_test_opt and friends should take a btrfs_fs_infofs/btrfs/ctree.h fs/btrfs/delayed-inode.c fs/btrfs/dev-replace.c +11 more+137 -1323 replies
4/31btrfs: tests, move initialization into tests/fs/btrfs/super.c fs/btrfs/tests/btrfs-tests.c fs/btrfs/tests/btrfs-tests.h+48 -772 replies
5/31btrfs: tests, require fs_info for rootfs/btrfs/ctree.h fs/btrfs/disk-io.c fs/btrfs/disk-io.h +7 more+103 -612 replies
6/31btrfs: tests, use BTRFS_FS_STATE_DUMMY_FS_INFO instead of dummy rootfs/btrfs/backref.c fs/btrfs/ctree.c fs/btrfs/ctree.h +4 more+19 -210 replies
7/31btrfs: simpilify btrfs_subvol_inherit_propsfs/btrfs/props.c+3 -30 replies
8/31btrfs: copy_to_sk drop unused root parameterfs/btrfs/ioctl.c+2 -30 replies
9/31btrfs: cleanup, remove prototype for btrfs_find_root_reffs/btrfs/ctree.h+0 -30 replies
10/31btrfs: introduce BTRFS_MAX_ITEM_SIZEfs/btrfs/ctree.h fs/btrfs/extent-tree.c fs/btrfs/file-item.c +1 more+8 -100 replies
11/31btrfs: convert nodesize macros to static inlinesfs/btrfs/ctree.h+33 -150 replies
12/31btrfs: btrfs_relocate_chunk pass extent_root to btrfs_end_transactionfs/btrfs/volumes.c+1 -10 replies
13/31btrfs: add btrfs_trans_handle->fs_info pointerfs/btrfs/extent-tree.c fs/btrfs/qgroup.c fs/btrfs/transaction.c +1 more+6 -40 replies
14/31btrfs: btrfs_abort_transaction, drop root parameterfs/btrfs/ctree.c fs/btrfs/ctree.h fs/btrfs/delayed-inode.c +14 more+147 -1520 replies
15/31btrfs: call functions that overwrite their root parameter with fs_infofs/btrfs/ctree.h fs/btrfs/disk-io.c fs/btrfs/extent-tree.c +7 more+52 -591 reply
16/31btrfs: call functions that always use the same root with fs_info insteadfs/btrfs/ctree.h fs/btrfs/disk-io.c fs/btrfs/disk-io.h +11 more+115 -1010 replies
17/31btrfs: btrfs_init_new_device should use fs_info->dev_rootfs/btrfs/ioctl.c fs/btrfs/volumes.c fs/btrfs/volumes.h+4 -30 replies
18/31btrfs: alloc_reserved_file_extent trace point should use extent_rootfs/btrfs/extent-tree.c+2 -10 replies
19/31btrfs: struct btrfsic_state->root should be an fs_infofs/btrfs/check-integrity.c+10 -100 replies
20/31btrfs: struct reada_control.root -> reada_control.fs_infofs/btrfs/ctree.h fs/btrfs/reada.c+8 -70 replies
21/31btrfs: root->fs_info cleanup, use fs_info->dev_root everywherefs/btrfs/check-integrity.c fs/btrfs/disk-io.c fs/btrfs/extent-tree.c +3 more+68 -710 replies
22/31btrfs: root->fs_info cleanup, io_ctl_initfs/btrfs/ctree.h fs/btrfs/free-space-cache.c+7 -70 replies
24/31btrfs: root->fs_info cleanup, btrfs_calc_{trans,trunc}_metadata_sizefs/btrfs/ctree.h fs/btrfs/delayed-inode.c fs/btrfs/extent-tree.c +6 more+34 -290 replies
25/31btrfs: root->fs_info cleanup, lock/unlock_chunksfs/btrfs/disk-io.c fs/btrfs/extent-tree.c fs/btrfs/free-space-cache.c +2 more+47 -470 replies
26/31btrfs: root->fs_info cleanup, update_block_group{,flags}fs/btrfs/extent-tree.c+14 -140 replies
28/31btrfs: root->fs_info cleanup, access fs_info->delayed_root directlyfs/btrfs/delayed-inode.c fs/btrfs/delayed-inode.h fs/btrfs/disk-io.c +1 more+13 -240 replies
30/31btrfs: root->fs_info cleanup, btrfs_commit_transaction already has rootfs/btrfs/dev-replace.c fs/btrfs/disk-io.c fs/btrfs/extent-tree.c +13 more+51 -540 replies
31/31btrfs: root->fs_info cleanup, btrfs_end_transaction{,_throttle} use trans->fs_info instead of parameterfs/btrfs/backref.c fs/btrfs/delayed-inode.c fs/btrfs/disk-io.c +16 more+123 -1290 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/31] btrfs: simplify use of struct btrfs_root pointers

From: Jeff Mahoney <[email protected]>

One of the common complaints I've heard from new and experienced developers alike about the btrfs code is the ubiquity of struct btrfs_root. There is one for every tree on disk and it's not always obvious which root is needed in a particular call path. It can be frustrating to spend time figuring out which root is required only to discover that it's not actually used for anything other than getting the fs-global struct btrfs_fs_info.

The patchset contains several sections.

1) The fsid trace event patchset I posted earlier; I can rebase without this but I'd prefer not to.

2) Converting btrfs_test_opt and friends to use an fs_info.

3) Converting tests to use an fs_info pointer whenever a root is used.

4) Moving sectorsize and nodesize to fs_info and cleaning up the macros used to access them.

5) General cleanups and small fixes to make the later patches easier to review.

6) Adding an "fs_info" convenience variable to every functiont that references root->fs_info more than once. As new references appear in functions, more of these are added later.

7) Call functions that always overwrite their root parameter with an fs_info instead.

8) Call functions that are always called using the same root with an fs_info instead, retreiving the root internally.

9) Convert every function that accepts a root argument but only uses it to retreive an fs_info to accept an fs_info instead. This is a recursive process as the changes percolate up.

10) Separately convert btrfs_commit_transaction and btrfs_end_transaction to use trans->root instead of a root parameter. Both are always called with the same root that was passed to btrfs_{start,join}_transaction.

This series of patches in email format is the "squashed" version of the full development series. That series is available at:

git://git.kernel.org/pub/scm/linux/kernel/git/jeffm/linux-btrfs.git

There are two branches of interest:
- btrfs-testing/root-fsinfo-cleanup-squashed contains this series
- btrfs-testing/root-fsinfo-cleanup contains the full series

The btrfs-testing/root-fsinfo-cleanup branch is easier to review if using git as each change is discrete. As a whole, the patchset is invasive but should change execution minimally. It passes and fails the same xfstests that the unpatched kernel does across multiple runs.

Thanks,

-Jeff

---

Jeff Mahoney (31):
btrfs: plumb fs_info into btrfs_work
btrfs: prefix fsid to all trace events
btrfs: btrfs_test_opt and friends should take a btrfs_fs_info
btrfs: tests, move initialization into tests/
btrfs: tests, require fs_info for root
btrfs: tests, use BTRFS_FS_STATE_DUMMY_FS_INFO instead of dummy root
btrfs: simpilify btrfs_subvol_inherit_props
btrfs: copy_to_sk drop unused root parameter
btrfs: cleanup, remove prototype for btrfs_find_root_ref
btrfs: introduce BTRFS_MAX_ITEM_SIZE
btrfs: convert nodesize macros to static inlines
btrfs: btrfs_relocate_chunk pass extent_root to btrfs_end_transaction
btrfs: add btrfs_trans_handle->fs_info pointer
btrfs: btrfs_abort_transaction, drop root parameter
btrfs: call functions that overwrite their root parameter with fs_info
btrfs: call functions that always use the same root with fs_info
instead
btrfs: btrfs_init_new_device should use fs_info->dev_root
btrfs: alloc_reserved_file_extent trace point should use extent_root
btrfs: struct btrfsic_state->root should be an fs_info
btrfs: struct reada_control.root -> reada_control.fs_info
btrfs: root->fs_info cleanup, use fs_info->dev_root everywhere
btrfs: root->fs_info cleanup, io_ctl_init
btrfs: pull node/sector/stripe sizes out of root and into fs_info
btrfs: root->fs_info cleanup, btrfs_calc_{trans,trunc}_metadata_size
btrfs: root->fs_info cleanup, lock/unlock_chunks
btrfs: root->fs_info cleanup, update_block_group{,flags}
btrfs: root->fs_info cleanup, add fs_info convenience variables
btrfs: root->fs_info cleanup, access fs_info->delayed_root directly
btrfs: take an fs_info parameter directly when the root is not used
otherwise
btrfs: root->fs_info cleanup, btrfs_commit_transaction already has
root
btrfs: root->fs_info cleanup, btrfs_end_transaction{,_throttle} use

    trans->fs_info instead of parameter
 fs/btrfs/async-thread.c                |   31 +-
 fs/btrfs/async-thread.h                |    6 +-
 fs/btrfs/backref.c                     |   12 +-
 fs/btrfs/check-integrity.c             |   41 +-
 fs/btrfs/check-integrity.h             |    5 +-
 fs/btrfs/compression.c                 |   54 +-
 fs/btrfs/ctree.c                       |  483 ++++++------
 fs/btrfs/ctree.h                       |  281 +++----
 fs/btrfs/delayed-inode.c               |  147 ++--
 fs/btrfs/delayed-inode.h               |   19 +-
 fs/btrfs/delayed-ref.c                 |    9 +-
 fs/btrfs/dev-replace.c                 |   68 +-
 fs/btrfs/dev-replace.h                 |    4 +-
 fs/btrfs/dir-item.c                    |   44 +-
 fs/btrfs/disk-io.c                     |  593 ++++++++-------
 fs/btrfs/disk-io.h                     |   27 +-
 fs/btrfs/export.c                      |   10 +-
 fs/btrfs/extent-tree.c                 | 1297 ++++++++++++++++----------------
 fs/btrfs/extent_io.c                   |   41 +-
 fs/btrfs/extent_io.h                   |    4 +-
 fs/btrfs/file-item.c                   |  164 ++--
 fs/btrfs/file.c                        |  220 +++---
 fs/btrfs/free-space-cache.c            |  116 +--
 fs/btrfs/free-space-cache.h            |    6 +-
 fs/btrfs/free-space-tree.c             |   60 +-
 fs/btrfs/inode-item.c                  |   11 +-
 fs/btrfs/inode-map.c                   |   48 +-
 fs/btrfs/inode.c                       |  834 ++++++++++----------
 fs/btrfs/ioctl.c                       |  613 ++++++++-------
 fs/btrfs/ordered-data.c                |   38 +-
 fs/btrfs/ordered-data.h                |    4 +-
 fs/btrfs/print-tree.c                  |   21 +-
 fs/btrfs/print-tree.h                  |    4 +-
 fs/btrfs/props.c                       |   11 +-
 fs/btrfs/qgroup.c                      |   60 +-
 fs/btrfs/qgroup.h                      |    9 +-
 fs/btrfs/raid56.c                      |   60 +-
 fs/btrfs/raid56.h                      |    8 +-
 fs/btrfs/reada.c                       |   36 +-
 fs/btrfs/relocation.c                  |  261 ++++---
 fs/btrfs/root-tree.c                   |   36 +-
 fs/btrfs/scrub.c                       |  177 +++--
 fs/btrfs/send.c                        |   45 +-
 fs/btrfs/super.c                       |  308 ++++----
 fs/btrfs/tests/btrfs-tests.c           |   72 +-
 fs/btrfs/tests/btrfs-tests.h           |   38 +-
 fs/btrfs/tests/extent-buffer-tests.c   |   23 +-
 fs/btrfs/tests/free-space-tests.c      |   14 +-
 fs/btrfs/tests/free-space-tree-tests.c |   18 +-
 fs/btrfs/tests/inode-tests.c           |   46 +-
 fs/btrfs/tests/qgroup-tests.c          |   23 +-
 fs/btrfs/transaction.c                 |  531 ++++++-------
 fs/btrfs/transaction.h                 |   16 +-
 fs/btrfs/tree-log.c                    |  193 ++---
 fs/btrfs/uuid-tree.c                   |   20 +-
 fs/btrfs/volumes.c                     |  813 ++++++++++----------
 fs/btrfs/volumes.h                     |   42 +-
 fs/btrfs/xattr.c                       |   21 +-
 include/trace/events/btrfs.h           |  296 ++++----
 59 files changed, 4383 insertions(+), 4109 deletions(-)
Signature · 1 line
2.7.1