btrfs: add forward declarations and headers, part 1
authorDavid Sterba <dsterba@suse.com>
Fri, 26 Jan 2024 23:53:06 +0000 (00:53 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 4 Mar 2024 15:24:49 +0000 (16:24 +0100)
Do a cleanup in the short headers:

- add forward declarations for types referenced by pointers
- add includes when types need them

This fixes potential compilation problems if the headers are reordered
or the missing includes are not provided indirectly.

Signed-off-by: David Sterba <dsterba@suse.com>
29 files changed:
fs/btrfs/acl.h
fs/btrfs/async-thread.h
fs/btrfs/defrag.h
fs/btrfs/delalloc-space.h
fs/btrfs/dev-replace.h
fs/btrfs/dir-item.h
fs/btrfs/disk-io.h
fs/btrfs/export.h
fs/btrfs/extent_map.h
fs/btrfs/file.h
fs/btrfs/ioctl.h
fs/btrfs/ordered-data.h
fs/btrfs/orphan.h
fs/btrfs/print-tree.h
fs/btrfs/props.c
fs/btrfs/props.h
fs/btrfs/raid-stripe-tree.h
fs/btrfs/rcu-string.h
fs/btrfs/ref-verify.h
fs/btrfs/reflink.h
fs/btrfs/relocation.h
fs/btrfs/root-tree.h
fs/btrfs/scrub.h
fs/btrfs/super.h
fs/btrfs/sysfs.h
fs/btrfs/tree-mod-log.h
fs/btrfs/uuid-tree.h
fs/btrfs/verity.h
fs/btrfs/xattr.h

index a270e71ec05f9125b53799ec080e9723e433d608..48b9ddae4a46a7d522055ffc95dfdd0c52a62472 100644 (file)
@@ -3,8 +3,15 @@
 #ifndef BTRFS_ACL_H
 #define BTRFS_ACL_H
 
+struct posix_acl;
+struct inode;
+struct btrfs_trans_handle;
+
 #ifdef CONFIG_BTRFS_FS_POSIX_ACL
 
+struct mnt_idmap;
+struct dentry;
+
 struct posix_acl *btrfs_get_acl(struct inode *inode, int type, bool rcu);
 int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                  struct posix_acl *acl, int type);
@@ -13,6 +20,10 @@ int __btrfs_set_acl(struct btrfs_trans_handle *trans, struct inode *inode,
 
 #else
 
+#include <linux/errno.h>
+
+struct btrfs_trans_handle;
+
 #define btrfs_get_acl NULL
 #define btrfs_set_acl NULL
 static inline int __btrfs_set_acl(struct btrfs_trans_handle *trans,
index 62b8a0d5789865378ac1cce504296eb13a3feb30..04c2f3175828bba19b5eb0062bbb2756527f8652 100644 (file)
@@ -7,11 +7,14 @@
 #ifndef BTRFS_ASYNC_THREAD_H
 #define BTRFS_ASYNC_THREAD_H
 
+#include <linux/compiler_types.h>
 #include <linux/workqueue.h>
+#include <linux/list.h>
 
 struct btrfs_fs_info;
 struct btrfs_workqueue;
 struct btrfs_work;
+
 typedef void (*btrfs_func_t)(struct btrfs_work *arg);
 typedef void (*btrfs_ordered_func_t)(struct btrfs_work *arg, bool);
 
index 5a62763528d1b53fefc99ae71ee315d6e04f87db..878528e086fbe8def22d432ae1666e2e063b1a3c 100644 (file)
@@ -3,6 +3,16 @@
 #ifndef BTRFS_DEFRAG_H
 #define BTRFS_DEFRAG_H
 
+#include <linux/types.h>
+#include <linux/compiler_types.h>
+
+struct inode;
+struct file_ra_state;
+struct btrfs_fs_info;
+struct btrfs_root;
+struct btrfs_trans_handle;
+struct btrfs_ioctl_defrag_range_args;
+
 int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
                      struct btrfs_ioctl_defrag_range_args *range,
                      u64 newer_than, unsigned long max_to_defrag);
index c5d573f2366e3750805c95264e6bcf517ed3ff2f..ce4f889e4f17b7602d8ca34c8baed1538803f5fa 100644 (file)
@@ -3,7 +3,11 @@
 #ifndef BTRFS_DELALLOC_SPACE_H
 #define BTRFS_DELALLOC_SPACE_H
 
+#include <linux/types.h>
+
 struct extent_changeset;
+struct btrfs_inode;
+struct btrfs_fs_info;
 
 int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes);
 int btrfs_check_data_free_space(struct btrfs_inode *inode,
index 675082ccec89f84de417ba4b620a825ef73dfac5..23e480efe5e6e4050ee593ba03508a75e782c2ad 100644 (file)
@@ -6,11 +6,15 @@
 #ifndef BTRFS_DEV_REPLACE_H
 #define BTRFS_DEV_REPLACE_H
 
+#include <linux/types.h>
+#include <linux/compiler_types.h>
+
 struct btrfs_ioctl_dev_replace_args;
 struct btrfs_fs_info;
 struct btrfs_trans_handle;
 struct btrfs_dev_replace;
 struct btrfs_block_group;
+struct btrfs_device;
 
 int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info);
 int btrfs_run_dev_replace(struct btrfs_trans_handle *trans);
index e40a226373d7ecb80ba66f548e8d794649a48885..00b3d83d7569e51aac3632edf8de5a0fa9def2b2 100644 (file)
@@ -3,9 +3,15 @@
 #ifndef BTRFS_DIR_ITEM_H
 #define BTRFS_DIR_ITEM_H
 
+#include <linux/types.h>
 #include <linux/crc32c.h>
 
 struct fscrypt_str;
+struct btrfs_fs_info;
+struct btrfs_key;
+struct btrfs_path;
+struct btrfs_root;
+struct btrfs_trans_handle;
 
 int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir,
                          const struct fscrypt_str *name);
index eb3473d1c1ac1b239092a594cf0f788f961b4943..a7ca734e2cb6a2bb81163e4fd90af64af17cac20 100644 (file)
@@ -6,6 +6,10 @@
 #ifndef BTRFS_DISK_IO_H
 #define BTRFS_DISK_IO_H
 
+#include <linux/sizes.h>
+#include "ctree.h"
+#include "fs.h"
+
 #define BTRFS_SUPER_MIRROR_MAX  3
 #define BTRFS_SUPER_MIRROR_SHIFT 12
 
index eba6bc4f5a619f92e15b1200eff0af744d200c8c..464582273af9262ff1e093f40eff67fa6bff6fdc 100644 (file)
@@ -4,6 +4,10 @@
 #define BTRFS_EXPORT_H
 
 #include <linux/exportfs.h>
+#include <linux/types.h>
+
+struct dentry;
+struct super_block;
 
 extern const struct export_operations btrfs_export_ops;
 
index e380fc08bbe4535757ddebb7ebd2d188fa81ccaf..7fd55cf91f53729c5fed73f0f2bb7f2d3b3871ba 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <linux/rbtree.h>
 #include <linux/refcount.h>
+#include "misc.h"
 #include "compression.h"
 
 #define EXTENT_MAP_LAST_BYTE ((u64)-4)
index 82b34fbb295f27e32b390c4780e02e289eff201d..77aaca208c7bce49da759bd5a123c50463c21402 100644 (file)
@@ -3,6 +3,21 @@
 #ifndef BTRFS_FILE_H
 #define BTRFS_FILE_H
 
+#include <linux/types.h>
+
+struct file;
+struct extent_state;
+struct kiocb;
+struct iov_iter;
+struct page;
+struct btrfs_ioctl_encoded_io_args;
+struct btrfs_drop_extents_args;
+struct btrfs_inode;
+struct btrfs_root;
+struct btrfs_path;
+struct btrfs_replace_extent_info;
+struct btrfs_trans_handle;
+
 extern const struct file_operations btrfs_file_operations;
 
 int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync);
index d51b9a2f2f6e88fa54876e28793def8b2ff483e0..2c5dc25ec67011dd8edfd8043fa12db583d51c60 100644 (file)
@@ -3,6 +3,15 @@
 #ifndef BTRFS_IOCTL_H
 #define BTRFS_IOCTL_H
 
+#include <linux/types.h>
+
+struct file;
+struct dentry;
+struct mnt_idmap;
+struct fileattr;
+struct btrfs_fs_info;
+struct btrfs_ioctl_balance_args;
+
 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 int btrfs_fileattr_get(struct dentry *dentry, struct fileattr *fa);
index 127ef8bf0ffd78a416d1b9074b1d6e22a785a477..6fc0521000ac8594a6d139a7e33a5f7c53394a25 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef BTRFS_ORDERED_DATA_H
 #define BTRFS_ORDERED_DATA_H
 
+#include "async-thread.h"
+
 struct btrfs_ordered_sum {
        /*
         * Logical start address and length for of the blocks covered by
index 3faab5cbb59ac9a9846c45473a8d01fb926de1e4..aa54a88a60de1eb0187aa4afcb123ec6424f7513 100644 (file)
@@ -3,6 +3,11 @@
 #ifndef BTRFS_ORPHAN_H
 #define BTRFS_ORPHAN_H
 
+#include <linux/types.h>
+
+struct btrfs_trans_handle;
+struct btrfs_root;
+
 int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans,
                             struct btrfs_root *root, u64 offset);
 int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,
index c42bc666d5eeab37bb5869f0305c34789896ddaf..8504bf1702c7a2a2107a358dcfab1aafcffc8de4 100644 (file)
@@ -9,6 +9,9 @@
 /* Buffer size to contain tree name and possibly additional data (offset) */
 #define BTRFS_ROOT_NAME_BUF_LEN                                48
 
+struct extent_buffer;
+struct btrfs_key;
+
 void btrfs_print_leaf(const struct extent_buffer *l);
 void btrfs_print_tree(const struct extent_buffer *c, bool follow);
 const char *btrfs_root_name(const struct btrfs_key *key, char *buf);
index ac4a0af2b554394791da383e02b471d89c831b98..2a9b7b029eeba3caccff7f8f5a83501c92f27260 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <linux/hashtable.h>
+#include <linux/xattr.h>
 #include "messages.h"
 #include "props.h"
 #include "btrfs_inode.h"
index 6e283196e38abab59512c6084d40e3cd23372a70..f60cd89feb2930231bf5b5e12a84b11c6770b1ec 100644 (file)
@@ -6,7 +6,12 @@
 #ifndef BTRFS_PROPS_H
 #define BTRFS_PROPS_H
 
-#include "ctree.h"
+#include <linux/compiler_types.h>
+
+struct inode;
+struct btrfs_inode;
+struct btrfs_path;
+struct btrfs_trans_handle;
 
 int __init btrfs_props_init(void);
 
index cdb58b38fcb5ea3ede8cd36a5e2dccf958b345aa..c9c258f849037464fbb9e7c8dafa203ca87f7b9e 100644 (file)
@@ -6,6 +6,10 @@
 #ifndef BTRFS_RAID_STRIPE_TREE_H
 #define BTRFS_RAID_STRIPE_TREE_H
 
+#include <linux/types.h>
+#include <uapi/linux/btrfs_tree.h>
+#include "fs.h"
+
 #define BTRFS_RST_SUPP_BLOCK_GROUP_MASK    (BTRFS_BLOCK_GROUP_DUP |            \
                                            BTRFS_BLOCK_GROUP_RAID1_MASK |      \
                                            BTRFS_BLOCK_GROUP_RAID0 |           \
@@ -13,6 +17,7 @@
 
 struct btrfs_io_context;
 struct btrfs_io_stripe;
+struct btrfs_fs_info;
 struct btrfs_ordered_extent;
 struct btrfs_trans_handle;
 
index 5c2b66d155ef7201296c3666a8d2e241781d444c..1c2d7cb1fe6f635bada8a97ae1f3b16a5d67e338 100644 (file)
@@ -6,6 +6,12 @@
 #ifndef BTRFS_RCU_STRING_H
 #define BTRFS_RCU_STRING_H
 
+#include <linux/types.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include <linux/rcupdate.h>
+#include <linux/printk.h>
+
 struct rcu_string {
        struct rcu_head rcu;
        char str[];
index 855de37719b546d4f8006833e5d0ab55b64b6c46..3511e1a5c96ba95079fe359a1abbe481fca01557 100644 (file)
@@ -6,7 +6,16 @@
 #ifndef BTRFS_REF_VERIFY_H
 #define BTRFS_REF_VERIFY_H
 
+#include <linux/types.h>
+#include <linux/rbtree_types.h>
+
+struct btrfs_fs_info;
+struct btrfs_ref;
+
 #ifdef CONFIG_BTRFS_FS_REF_VERIFY
+
+#include <linux/spinlock.h>
+
 int btrfs_build_ref_tree(struct btrfs_fs_info *fs_info);
 void btrfs_free_ref_cache(struct btrfs_fs_info *fs_info);
 int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
index ecb309b4dad0fc06fb23e8d4dc9e20beabc9cd6e..1e291f7d85c42806f10d5ab0bf9d18dfe1195cd0 100644 (file)
@@ -3,7 +3,9 @@
 #ifndef BTRFS_REFLINK_H
 #define BTRFS_REFLINK_H
 
-#include <linux/fs.h>
+#include <linux/types.h>
+
+struct file;
 
 loff_t btrfs_remap_file_range(struct file *file_in, loff_t pos_in,
                              struct file *file_out, loff_t pos_out,
index 5fb60f2deb5305cdb899b592e2b8b5bb4161d643..788c86d8633aff2b220166d1af34b054a28e53f7 100644 (file)
@@ -3,6 +3,15 @@
 #ifndef BTRFS_RELOCATION_H
 #define BTRFS_RELOCATION_H
 
+#include <linux/types.h>
+
+struct extent_buffer;
+struct btrfs_fs_info;
+struct btrfs_root;
+struct btrfs_trans_handle;
+struct btrfs_ordered_extent;
+struct btrfs_pending_snapshot;
+
 int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start);
 int btrfs_init_reloc_root(struct btrfs_trans_handle *trans, struct btrfs_root *root);
 int btrfs_update_reloc_root(struct btrfs_trans_handle *trans,
index 8b2c3859e4647a4366bbb4b87b736916dae14b20..6f929cf3bd4967560964659ee9f631e6766a07ab 100644 (file)
@@ -3,7 +3,17 @@
 #ifndef BTRFS_ROOT_TREE_H
 #define BTRFS_ROOT_TREE_H
 
+#include <linux/types.h>
+
 struct fscrypt_str;
+struct extent_buffer;
+struct btrfs_key;
+struct btrfs_root;
+struct btrfs_root_item;
+struct btrfs_path;
+struct btrfs_fs_info;
+struct btrfs_block_rsv;
+struct btrfs_trans_handle;
 
 int btrfs_subvolume_reserve_metadata(struct btrfs_root *root,
                                     struct btrfs_block_rsv *rsv,
index 7639103ebf9df3fb9d79fe2c48aa76fbe10df768..f0df597b75c7c747c320db01551c761431c6f2ae 100644 (file)
@@ -3,6 +3,12 @@
 #ifndef BTRFS_SCRUB_H
 #define BTRFS_SCRUB_H
 
+#include <linux/types.h>
+
+struct btrfs_fs_info;
+struct btrfs_device;
+struct btrfs_scrub_progress;
+
 int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
                    u64 end, struct btrfs_scrub_progress *progress,
                    int readonly, int is_dev_replace);
index f18253ca280d3e49722d4a665406ce370d6ec05d..cbcab434b5ecb9f225d4cae1d94d7c5b0af8154a 100644 (file)
@@ -3,6 +3,13 @@
 #ifndef BTRFS_SUPER_H
 #define BTRFS_SUPER_H
 
+#include <linux/types.h>
+#include <linux/fs.h>
+#include "fs.h"
+
+struct super_block;
+struct btrfs_fs_info;
+
 bool btrfs_check_options(struct btrfs_fs_info *info, unsigned long *mount_opt,
                         unsigned long flags);
 int btrfs_sync_fs(struct super_block *sb, int wait);
index 86c7eef128731ea5aa88efefb8a43d251d8fad34..e6a284c59809c9696eb1fa8cb1e2f29c800acf37 100644 (file)
@@ -3,8 +3,17 @@
 #ifndef BTRFS_SYSFS_H
 #define BTRFS_SYSFS_H
 
+#include <linux/types.h>
+#include <linux/compiler_types.h>
 #include <linux/kobject.h>
 
+struct btrfs_fs_info;
+struct btrfs_device;
+struct btrfs_fs_devices;
+struct btrfs_block_group;
+struct btrfs_space_info;
+struct btrfs_qgroup;
+
 enum btrfs_feature_set {
        FEAT_COMPAT,
        FEAT_COMPAT_RO,
index 94f10afeee9725496e3e05e310b3a594276e0c33..ff00c8e8a393cb201986ded99b1b161dddfd92b0 100644 (file)
@@ -3,7 +3,13 @@
 #ifndef BTRFS_TREE_MOD_LOG_H
 #define BTRFS_TREE_MOD_LOG_H
 
-#include "ctree.h"
+#include <linux/list.h>
+
+struct extent_buffer;
+struct btrfs_fs_info;
+struct btrfs_path;
+struct btrfs_root;
+struct btrfs_seq_list;
 
 /* Represents a tree mod log user. */
 struct btrfs_seq_list {
index 5350c87fe2caf3497bdec256b0828fa2f331906a..080ede0227aee0bb7986a537c5ee4f988d3d2f11 100644 (file)
@@ -3,6 +3,11 @@
 #ifndef BTRFS_UUID_TREE_H
 #define BTRFS_UUID_TREE_H
 
+#include <linux/types.h>
+
+struct btrfs_trans_handle;
+struct btrfs_fs_info;
+
 int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans, u8 *uuid, u8 type,
                        u64 subid);
 int btrfs_uuid_tree_remove(struct btrfs_trans_handle *trans, u8 *uuid, u8 type,
index 91c10f7d0a46543aa19d6cbef3eceb9ed72542c2..d696659e43e43d7221dcc56f848238d0c1a413e0 100644 (file)
@@ -3,8 +3,13 @@
 #ifndef BTRFS_VERITY_H
 #define BTRFS_VERITY_H
 
+struct inode;
+struct btrfs_inode;
+
 #ifdef CONFIG_FS_VERITY
 
+#include <linux/fsverity.h>
+
 extern const struct fsverity_operations btrfs_verityops;
 
 int btrfs_drop_verity_items(struct btrfs_inode *inode);
@@ -12,6 +17,8 @@ int btrfs_get_verity_descriptor(struct inode *inode, void *buf, size_t buf_size)
 
 #else
 
+#include <linux/errno.h>
+
 static inline int btrfs_drop_verity_items(struct btrfs_inode *inode)
 {
        return 0;
index 118118ca3e1de7a04bb33a581f9b397755fb7932..b9376ea258ff327025b08c8529dcd15ceec24afa 100644 (file)
@@ -6,7 +6,11 @@
 #ifndef BTRFS_XATTR_H
 #define BTRFS_XATTR_H
 
-#include <linux/xattr.h>
+struct dentry;
+struct inode;
+struct qstr;
+struct xattr_handler;
+struct btrfs_trans_handle;
 
 extern const struct xattr_handler * const btrfs_xattr_handlers[];