Skip to content

Commit 6b6f6f2

Browse files
adam900710kdave
authored andcommitted
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> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 2a362fc commit 6b6f6f2

21 files changed

+21
-22
lines changed

fs/btrfs/accessors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/string.h>
1313
#include <linux/mm.h>
1414
#include <uapi/linux/btrfs_tree.h>
15+
#include "fs.h"
1516
#include "extent_io.h"
1617

1718
struct extent_buffer;

fs/btrfs/btrfs_inode.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@
1818
#include <linux/lockdep.h>
1919
#include <uapi/linux/btrfs_tree.h>
2020
#include <trace/events/btrfs.h>
21+
#include "ctree.h"
2122
#include "block-rsv.h"
2223
#include "extent_map.h"
23-
#include "extent_io.h"
2424
#include "extent-io-tree.h"
25-
#include "ordered-data.h"
26-
#include "delayed-inode.h"
2725

28-
struct extent_state;
2926
struct posix_acl;
3027
struct iov_iter;
3128
struct writeback_control;
3229
struct btrfs_root;
3330
struct btrfs_fs_info;
3431
struct btrfs_trans_handle;
32+
struct btrfs_bio;
33+
struct btrfs_file_extent;
34+
struct btrfs_delayed_node;
3535

3636
/*
3737
* Since we search a directory based on f_pos (struct dir_context::pos) we have

fs/btrfs/compression.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@
1414
#include <linux/pagemap.h>
1515
#include "bio.h"
1616
#include "fs.h"
17-
#include "messages.h"
1817

1918
struct address_space;
20-
struct page;
2119
struct inode;
2220
struct btrfs_inode;
2321
struct btrfs_ordered_extent;
24-
struct btrfs_bio;
2522

2623
/*
2724
* We want to make sure that amount of RAM required to uncompress an extent is

fs/btrfs/ctree.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
#include <linux/refcount.h>
1818
#include <uapi/linux/btrfs_tree.h>
1919
#include "locking.h"
20-
#include "fs.h"
2120
#include "accessors.h"
22-
#include "extent-io-tree.h"
2321

2422
struct extent_buffer;
2523
struct btrfs_block_rsv;

fs/btrfs/defrag.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "defrag.h"
1616
#include "file-item.h"
1717
#include "super.h"
18+
#include "compression.h"
1819

1920
static struct kmem_cache *btrfs_inode_defrag_cachep;
2021

fs/btrfs/dir-item.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "transaction.h"
1010
#include "accessors.h"
1111
#include "dir-item.h"
12+
#include "delayed-inode.h"
1213

1314
/*
1415
* insert a name into a directory, doing overflow properly if there is a hash

fs/btrfs/direct-io.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "fs.h"
1111
#include "transaction.h"
1212
#include "volumes.h"
13+
#include "bio.h"
14+
#include "ordered-data.h"
1315

1416
struct btrfs_dio_data {
1517
ssize_t submitted;

fs/btrfs/disk-io.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "relocation.h"
5151
#include "scrub.h"
5252
#include "super.h"
53+
#include "delayed-inode.h"
5354

5455
#define BTRFS_SUPER_FLAG_SUPP (BTRFS_HEADER_FLAG_WRITTEN |\
5556
BTRFS_HEADER_FLAG_RELOC |\

fs/btrfs/disk-io.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
#include <linux/sizes.h>
1010
#include <linux/compiler_types.h>
1111
#include "ctree.h"
12-
#include "fs.h"
12+
#include "bio.h"
13+
#include "ordered-data.h"
1314

1415
struct block_device;
1516
struct super_block;

fs/btrfs/extent-tree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "orphan.h"
4141
#include "tree-checker.h"
4242
#include "raid-stripe-tree.h"
43+
#include "delayed-inode.h"
4344

4445
#undef SCRAMBLE_DELAYED_REFS
4546

0 commit comments

Comments
 (0)