btrfs: add forward declarations and headers, part 1

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>
This commit is contained in:
David Sterba 2024-01-27 00:53:06 +01:00
parent e84bfffc4b
commit 22b46bdc5f
29 changed files with 176 additions and 4 deletions

View File

@ -3,8 +3,15 @@
#ifndef BTRFS_ACL_H #ifndef BTRFS_ACL_H
#define BTRFS_ACL_H #define BTRFS_ACL_H
struct posix_acl;
struct inode;
struct btrfs_trans_handle;
#ifdef CONFIG_BTRFS_FS_POSIX_ACL #ifdef CONFIG_BTRFS_FS_POSIX_ACL
struct mnt_idmap;
struct dentry;
struct posix_acl *btrfs_get_acl(struct inode *inode, int type, bool rcu); struct posix_acl *btrfs_get_acl(struct inode *inode, int type, bool rcu);
int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type); struct posix_acl *acl, int type);
@ -13,6 +20,10 @@ int __btrfs_set_acl(struct btrfs_trans_handle *trans, struct inode *inode,
#else #else
#include <linux/errno.h>
struct btrfs_trans_handle;
#define btrfs_get_acl NULL #define btrfs_get_acl NULL
#define btrfs_set_acl NULL #define btrfs_set_acl NULL
static inline int __btrfs_set_acl(struct btrfs_trans_handle *trans, static inline int __btrfs_set_acl(struct btrfs_trans_handle *trans,

View File

@ -7,11 +7,14 @@
#ifndef BTRFS_ASYNC_THREAD_H #ifndef BTRFS_ASYNC_THREAD_H
#define BTRFS_ASYNC_THREAD_H #define BTRFS_ASYNC_THREAD_H
#include <linux/compiler_types.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/list.h>
struct btrfs_fs_info; struct btrfs_fs_info;
struct btrfs_workqueue; struct btrfs_workqueue;
struct btrfs_work; struct btrfs_work;
typedef void (*btrfs_func_t)(struct btrfs_work *arg); typedef void (*btrfs_func_t)(struct btrfs_work *arg);
typedef void (*btrfs_ordered_func_t)(struct btrfs_work *arg, bool); typedef void (*btrfs_ordered_func_t)(struct btrfs_work *arg, bool);

View File

@ -3,6 +3,16 @@
#ifndef BTRFS_DEFRAG_H #ifndef BTRFS_DEFRAG_H
#define 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, int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
struct btrfs_ioctl_defrag_range_args *range, struct btrfs_ioctl_defrag_range_args *range,
u64 newer_than, unsigned long max_to_defrag); u64 newer_than, unsigned long max_to_defrag);

View File

@ -3,7 +3,11 @@
#ifndef BTRFS_DELALLOC_SPACE_H #ifndef BTRFS_DELALLOC_SPACE_H
#define BTRFS_DELALLOC_SPACE_H #define BTRFS_DELALLOC_SPACE_H
#include <linux/types.h>
struct extent_changeset; struct extent_changeset;
struct btrfs_inode;
struct btrfs_fs_info;
int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes); int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes);
int btrfs_check_data_free_space(struct btrfs_inode *inode, int btrfs_check_data_free_space(struct btrfs_inode *inode,

View File

@ -6,11 +6,15 @@
#ifndef BTRFS_DEV_REPLACE_H #ifndef BTRFS_DEV_REPLACE_H
#define 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_ioctl_dev_replace_args;
struct btrfs_fs_info; struct btrfs_fs_info;
struct btrfs_trans_handle; struct btrfs_trans_handle;
struct btrfs_dev_replace; struct btrfs_dev_replace;
struct btrfs_block_group; struct btrfs_block_group;
struct btrfs_device;
int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info); int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info);
int btrfs_run_dev_replace(struct btrfs_trans_handle *trans); int btrfs_run_dev_replace(struct btrfs_trans_handle *trans);

View File

@ -3,9 +3,15 @@
#ifndef BTRFS_DIR_ITEM_H #ifndef BTRFS_DIR_ITEM_H
#define BTRFS_DIR_ITEM_H #define BTRFS_DIR_ITEM_H
#include <linux/types.h>
#include <linux/crc32c.h> #include <linux/crc32c.h>
struct fscrypt_str; 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, int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir,
const struct fscrypt_str *name); const struct fscrypt_str *name);

View File

@ -6,6 +6,10 @@
#ifndef BTRFS_DISK_IO_H #ifndef BTRFS_DISK_IO_H
#define 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_MAX 3
#define BTRFS_SUPER_MIRROR_SHIFT 12 #define BTRFS_SUPER_MIRROR_SHIFT 12

View File

@ -4,6 +4,10 @@
#define BTRFS_EXPORT_H #define BTRFS_EXPORT_H
#include <linux/exportfs.h> #include <linux/exportfs.h>
#include <linux/types.h>
struct dentry;
struct super_block;
extern const struct export_operations btrfs_export_ops; extern const struct export_operations btrfs_export_ops;

View File

@ -5,6 +5,7 @@
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include <linux/refcount.h> #include <linux/refcount.h>
#include "misc.h"
#include "compression.h" #include "compression.h"
#define EXTENT_MAP_LAST_BYTE ((u64)-4) #define EXTENT_MAP_LAST_BYTE ((u64)-4)

View File

@ -3,6 +3,21 @@
#ifndef BTRFS_FILE_H #ifndef BTRFS_FILE_H
#define 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; extern const struct file_operations btrfs_file_operations;
int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync); int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync);

View File

@ -3,6 +3,15 @@
#ifndef BTRFS_IOCTL_H #ifndef BTRFS_IOCTL_H
#define 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_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
long btrfs_compat_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); int btrfs_fileattr_get(struct dentry *dentry, struct fileattr *fa);

View File

@ -6,6 +6,8 @@
#ifndef BTRFS_ORDERED_DATA_H #ifndef BTRFS_ORDERED_DATA_H
#define BTRFS_ORDERED_DATA_H #define BTRFS_ORDERED_DATA_H
#include "async-thread.h"
struct btrfs_ordered_sum { struct btrfs_ordered_sum {
/* /*
* Logical start address and length for of the blocks covered by * Logical start address and length for of the blocks covered by

View File

@ -3,6 +3,11 @@
#ifndef BTRFS_ORPHAN_H #ifndef BTRFS_ORPHAN_H
#define 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, int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans,
struct btrfs_root *root, u64 offset); struct btrfs_root *root, u64 offset);
int btrfs_del_orphan_item(struct btrfs_trans_handle *trans, int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,

View File

@ -9,6 +9,9 @@
/* Buffer size to contain tree name and possibly additional data (offset) */ /* Buffer size to contain tree name and possibly additional data (offset) */
#define BTRFS_ROOT_NAME_BUF_LEN 48 #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_leaf(const struct extent_buffer *l);
void btrfs_print_tree(const struct extent_buffer *c, bool follow); void btrfs_print_tree(const struct extent_buffer *c, bool follow);
const char *btrfs_root_name(const struct btrfs_key *key, char *buf); const char *btrfs_root_name(const struct btrfs_key *key, char *buf);

View File

@ -4,6 +4,7 @@
*/ */
#include <linux/hashtable.h> #include <linux/hashtable.h>
#include <linux/xattr.h>
#include "messages.h" #include "messages.h"
#include "props.h" #include "props.h"
#include "btrfs_inode.h" #include "btrfs_inode.h"

View File

@ -6,7 +6,12 @@
#ifndef BTRFS_PROPS_H #ifndef BTRFS_PROPS_H
#define 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); int __init btrfs_props_init(void);

View File

@ -6,6 +6,10 @@
#ifndef BTRFS_RAID_STRIPE_TREE_H #ifndef BTRFS_RAID_STRIPE_TREE_H
#define 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 | \ #define BTRFS_RST_SUPP_BLOCK_GROUP_MASK (BTRFS_BLOCK_GROUP_DUP | \
BTRFS_BLOCK_GROUP_RAID1_MASK | \ BTRFS_BLOCK_GROUP_RAID1_MASK | \
BTRFS_BLOCK_GROUP_RAID0 | \ BTRFS_BLOCK_GROUP_RAID0 | \
@ -13,6 +17,7 @@
struct btrfs_io_context; struct btrfs_io_context;
struct btrfs_io_stripe; struct btrfs_io_stripe;
struct btrfs_fs_info;
struct btrfs_ordered_extent; struct btrfs_ordered_extent;
struct btrfs_trans_handle; struct btrfs_trans_handle;

View File

@ -6,6 +6,12 @@
#ifndef BTRFS_RCU_STRING_H #ifndef BTRFS_RCU_STRING_H
#define 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_string {
struct rcu_head rcu; struct rcu_head rcu;
char str[]; char str[];

View File

@ -6,7 +6,16 @@
#ifndef BTRFS_REF_VERIFY_H #ifndef BTRFS_REF_VERIFY_H
#define 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 #ifdef CONFIG_BTRFS_FS_REF_VERIFY
#include <linux/spinlock.h>
int btrfs_build_ref_tree(struct btrfs_fs_info *fs_info); int btrfs_build_ref_tree(struct btrfs_fs_info *fs_info);
void btrfs_free_ref_cache(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, int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,

View File

@ -3,7 +3,9 @@
#ifndef BTRFS_REFLINK_H #ifndef BTRFS_REFLINK_H
#define 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, loff_t btrfs_remap_file_range(struct file *file_in, loff_t pos_in,
struct file *file_out, loff_t pos_out, struct file *file_out, loff_t pos_out,

View File

@ -3,6 +3,15 @@
#ifndef BTRFS_RELOCATION_H #ifndef BTRFS_RELOCATION_H
#define 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_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_init_reloc_root(struct btrfs_trans_handle *trans, struct btrfs_root *root);
int btrfs_update_reloc_root(struct btrfs_trans_handle *trans, int btrfs_update_reloc_root(struct btrfs_trans_handle *trans,

View File

@ -3,7 +3,17 @@
#ifndef BTRFS_ROOT_TREE_H #ifndef BTRFS_ROOT_TREE_H
#define BTRFS_ROOT_TREE_H #define BTRFS_ROOT_TREE_H
#include <linux/types.h>
struct fscrypt_str; 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, int btrfs_subvolume_reserve_metadata(struct btrfs_root *root,
struct btrfs_block_rsv *rsv, struct btrfs_block_rsv *rsv,

View File

@ -3,6 +3,12 @@
#ifndef BTRFS_SCRUB_H #ifndef BTRFS_SCRUB_H
#define 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, int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
u64 end, struct btrfs_scrub_progress *progress, u64 end, struct btrfs_scrub_progress *progress,
int readonly, int is_dev_replace); int readonly, int is_dev_replace);

View File

@ -3,6 +3,13 @@
#ifndef BTRFS_SUPER_H #ifndef BTRFS_SUPER_H
#define 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, bool btrfs_check_options(struct btrfs_fs_info *info, unsigned long *mount_opt,
unsigned long flags); unsigned long flags);
int btrfs_sync_fs(struct super_block *sb, int wait); int btrfs_sync_fs(struct super_block *sb, int wait);

View File

@ -3,8 +3,17 @@
#ifndef BTRFS_SYSFS_H #ifndef BTRFS_SYSFS_H
#define BTRFS_SYSFS_H #define BTRFS_SYSFS_H
#include <linux/types.h>
#include <linux/compiler_types.h>
#include <linux/kobject.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 { enum btrfs_feature_set {
FEAT_COMPAT, FEAT_COMPAT,
FEAT_COMPAT_RO, FEAT_COMPAT_RO,

View File

@ -3,7 +3,13 @@
#ifndef BTRFS_TREE_MOD_LOG_H #ifndef BTRFS_TREE_MOD_LOG_H
#define 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. */ /* Represents a tree mod log user. */
struct btrfs_seq_list { struct btrfs_seq_list {

View File

@ -3,6 +3,11 @@
#ifndef BTRFS_UUID_TREE_H #ifndef BTRFS_UUID_TREE_H
#define 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, int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans, u8 *uuid, u8 type,
u64 subid); u64 subid);
int btrfs_uuid_tree_remove(struct btrfs_trans_handle *trans, u8 *uuid, u8 type, int btrfs_uuid_tree_remove(struct btrfs_trans_handle *trans, u8 *uuid, u8 type,

View File

@ -3,8 +3,13 @@
#ifndef BTRFS_VERITY_H #ifndef BTRFS_VERITY_H
#define BTRFS_VERITY_H #define BTRFS_VERITY_H
struct inode;
struct btrfs_inode;
#ifdef CONFIG_FS_VERITY #ifdef CONFIG_FS_VERITY
#include <linux/fsverity.h>
extern const struct fsverity_operations btrfs_verityops; extern const struct fsverity_operations btrfs_verityops;
int btrfs_drop_verity_items(struct btrfs_inode *inode); 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 #else
#include <linux/errno.h>
static inline int btrfs_drop_verity_items(struct btrfs_inode *inode) static inline int btrfs_drop_verity_items(struct btrfs_inode *inode)
{ {
return 0; return 0;

View File

@ -6,7 +6,11 @@
#ifndef BTRFS_XATTR_H #ifndef BTRFS_XATTR_H
#define 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[]; extern const struct xattr_handler * const btrfs_xattr_handlers[];