]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: headers cleanup to remove unnecessary local includes
authorQu Wenruo <wqu@suse.com>
Mon, 27 Oct 2025 23:36:36 +0000 (10:06 +1030)
committerDavid Sterba <dsterba@suse.com>
Mon, 24 Nov 2025 21:34:52 +0000 (22:34 +0100)
commitc5667f9c8eb90293dfa4e52c65eb89fe39f5652d
treeacb1c8568008ecaeb652899fb45b736f85611254
parentafc04c8b1bb5552e6f7e05b4fe02ebc451fe66ff
btrfs: headers cleanup to remove unnecessary local includes

[BUG]
When I tried to remove btrfs_bio::fs_info and use btrfs_bio::inode to
grab the fs_info, the header "btrfs_inode.h" is needed to access the
full btrfs_inode structure.

Then btrfs will fail to compile.

[CAUSE]
There is a recursive including chain:

  "bio.h" -> "btrfs_inode.h" -> "extent_map.h" -> "compression.h" ->
  "bio.h"

That recursive including is causing problems for btrfs.

[ENHANCEMENT]
To reduce the risk of recursive including:

- Remove unnecessary local includes from btrfs headers
  Either the included header is pulled in by other headers, or is
  completely unnecessary.

- Remove btrfs local includes if the header only requires a pointer
  In that case let the implementing C file to pull the required header.

  This is especially important for headers like "btrfs_inode.h" which
  pulls in a lot of other btrfs headers, thus it's a mine field of
  recursive including.

- Remove unnecessary temporary structure definition
  Either if we have included the header defining the structure, or
  completely unused.

Now including "btrfs_inode.h" inside "bio.h" is completely fine,
although "btrfs_inode.h" still includes "extent_map.h", but that header
only includes "fs.h", no more chain back to "bio.h".

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
21 files changed:
fs/btrfs/accessors.h
fs/btrfs/btrfs_inode.h
fs/btrfs/compression.h
fs/btrfs/ctree.h
fs/btrfs/defrag.c
fs/btrfs/dir-item.c
fs/btrfs/direct-io.c
fs/btrfs/disk-io.c
fs/btrfs/disk-io.h
fs/btrfs/extent-tree.c
fs/btrfs/extent_io.h
fs/btrfs/extent_map.h
fs/btrfs/file-item.h
fs/btrfs/inode.c
fs/btrfs/space-info.c
fs/btrfs/subpage.h
fs/btrfs/transaction.c
fs/btrfs/transaction.h
fs/btrfs/tree-log.c
fs/btrfs/tree-log.h
fs/btrfs/zoned.h