1/* SPDX-License-Identifier: GPL-2.0 */
2
3#ifndef BTRFS_DEFRAG_H
4#define BTRFS_DEFRAG_H
5
6#include <linux/types.h>
7#include <linux/compiler_types.h>
8
9struct inode;
10struct file_ra_state;
11struct btrfs_fs_info;
12struct btrfs_root;
13struct btrfs_trans_handle;
14struct btrfs_ioctl_defrag_range_args;
15
16int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
17		      struct btrfs_ioctl_defrag_range_args *range,
18		      u64 newer_than, unsigned long max_to_defrag);
19int __init btrfs_auto_defrag_init(void);
20void __cold btrfs_auto_defrag_exit(void);
21int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans,
22			   struct btrfs_inode *inode, u32 extent_thresh);
23int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info);
24void btrfs_cleanup_defrag_inodes(struct btrfs_fs_info *fs_info);
25int btrfs_defrag_root(struct btrfs_root *root);
26
27static inline int btrfs_defrag_cancelled(struct btrfs_fs_info *fs_info)
28{
29	return signal_pending(current);
30}
31
32#endif
33