btrfs: move defrag related prototypes to their own header
authorJosef Bacik <josef@toxicpanda.com>
Wed, 26 Oct 2022 19:08:25 +0000 (15:08 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 5 Dec 2022 17:00:46 +0000 (18:00 +0100)
Now that the defrag code is all in one file, create a defrag.h and move
all the defrag related prototypes and helper out of ctree.h and into
defrag.h.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/defrag.c
fs/btrfs/defrag.h [new file with mode: 0644]
fs/btrfs/disk-io.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/super.c
fs/btrfs/transaction.c

index a9267b1178605768d0dfaa905a54ff1d87099d3b..689220637d002ab0afa5abf22f50dc04fde3543d 100644 (file)
@@ -773,19 +773,10 @@ int btrfs_fileattr_set(struct user_namespace *mnt_userns,
 int btrfs_ioctl_get_supported_features(void __user *arg);
 void btrfs_sync_inode_flags_to_i_flags(struct inode *inode);
 int __pure btrfs_is_empty_uuid(u8 *uuid);
-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);
 void btrfs_update_ioctl_balance_args(struct btrfs_fs_info *fs_info,
                               struct btrfs_ioctl_balance_args *bargs);
 
 /* file.c */
-int __init btrfs_auto_defrag_init(void);
-void __cold btrfs_auto_defrag_exit(void);
-int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans,
-                          struct btrfs_inode *inode, u32 extent_thresh);
-int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info);
-void btrfs_cleanup_defrag_inodes(struct btrfs_fs_info *fs_info);
 int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync);
 extern const struct file_operations btrfs_file_operations;
 int btrfs_drop_extents(struct btrfs_trans_handle *trans,
@@ -811,10 +802,6 @@ void btrfs_check_nocow_unlock(struct btrfs_inode *inode);
 bool btrfs_find_delalloc_in_range(struct btrfs_inode *inode, u64 start, u64 end,
                                  u64 *delalloc_start_ret, u64 *delalloc_end_ret);
 
-/* tree-defrag.c */
-int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
-                       struct btrfs_root *root);
-
 /* super.c */
 int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
                        unsigned long new_flags);
@@ -945,11 +932,6 @@ static inline int is_fstree(u64 rootid)
        return 0;
 }
 
-static inline int btrfs_defrag_cancelled(struct btrfs_fs_info *fs_info)
-{
-       return signal_pending(current);
-}
-
 /* verity.c */
 #ifdef CONFIG_FS_VERITY
 
index 2c260eef40d45f43564108599d81614c0ed80243..291263f93e476d02554bac09a9462d4b094adcf7 100644 (file)
@@ -13,6 +13,7 @@
 #include "messages.h"
 #include "delalloc-space.h"
 #include "subpage.h"
+#include "defrag.h"
 
 static struct kmem_cache *btrfs_inode_defrag_cachep;
 
diff --git a/fs/btrfs/defrag.h b/fs/btrfs/defrag.h
new file mode 100644 (file)
index 0000000..5305f22
--- /dev/null
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef BTRFS_DEFRAG_H
+#define BTRFS_DEFRAG_H
+
+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);
+int __init btrfs_auto_defrag_init(void);
+void __cold btrfs_auto_defrag_exit(void);
+int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans,
+                          struct btrfs_inode *inode, u32 extent_thresh);
+int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info);
+void btrfs_cleanup_defrag_inodes(struct btrfs_fs_info *fs_info);
+int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, struct btrfs_root *root);
+
+static inline int btrfs_defrag_cancelled(struct btrfs_fs_info *fs_info)
+{
+       return signal_pending(current);
+}
+
+#endif
index ebc9baab0e47fd3aab76220089fb9a605f9b8259..2f7dd79a5a35987e06f2e15acc358f4ee293f091 100644 (file)
@@ -47,6 +47,7 @@
 #include "accessors.h"
 #include "extent-tree.h"
 #include "root-tree.h"
+#include "defrag.h"
 
 #define BTRFS_SUPER_FLAG_SUPP  (BTRFS_HEADER_FLAG_WRITTEN |\
                                 BTRFS_HEADER_FLAG_RELOC |\
index 5b9857e30a08c40665f560a103c36c4f1e7dda96..97f28e37ec7cc9625ea7185f38bed192280d7dec 100644 (file)
@@ -59,6 +59,7 @@
 #include "accessors.h"
 #include "extent-tree.h"
 #include "root-tree.h"
+#include "defrag.h"
 
 struct btrfs_iget_args {
        u64 ino;
index 42453dd2ed313a095dcc64d967c6a12e7ced05af..f91dbd1dc6d1c4685c921591ed6591e1d2955cca 100644 (file)
@@ -54,6 +54,7 @@
 #include "accessors.h"
 #include "extent-tree.h"
 #include "root-tree.h"
+#include "defrag.h"
 
 #ifdef CONFIG_64BIT
 /* If we have a 32-bit userspace and 64-bit kernel, then the UAPI
index a4030dfeb2f2d5bab0c6c72abeec0bbbcae30704..f105d360d6c950561c4f374c2adc9b1c50498735 100644 (file)
@@ -52,6 +52,7 @@
 #include "raid56.h"
 #include "fs.h"
 #include "accessors.h"
+#include "defrag.h"
 #define CREATE_TRACE_POINTS
 #include <trace/events/btrfs.h>
 
index 82b2e2ec90cf0abfa5b3df71155a17e153f8c4e8..99d3f2a662275969e307551b989e2fbdb53943f9 100644 (file)
@@ -28,6 +28,7 @@
 #include "accessors.h"
 #include "extent-tree.h"
 #include "root-tree.h"
+#include "defrag.h"
 
 static struct kmem_cache *btrfs_trans_handle_cachep;