1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_REBALANCE_H
3 #define _BCACHEFS_REBALANCE_H
6 #include "disk_groups.h"
8 #include "rebalance_types.h"
10 static inline struct bch_extent_rebalance io_opts_to_rebalance_opts(struct bch_fs *c,
11 struct bch_io_opts *opts)
13 struct bch_extent_rebalance r = {
14 .type = BIT(BCH_EXTENT_ENTRY_rebalance),
16 ._name = opts->_name, \
17 ._name##_from_inode = opts->_name##_from_inode,
22 if (r.background_target &&
23 !bch2_target_accepts_data(c, BCH_DATA_user, r.background_target))
24 r.background_target = 0;
29 u64 bch2_bkey_sectors_need_rebalance(struct bch_fs *, struct bkey_s_c);
30 int bch2_bkey_set_needs_rebalance(struct bch_fs *, struct bch_io_opts *, struct bkey_i *);
31 int bch2_get_update_rebalance_opts(struct btree_trans *,
36 int bch2_set_rebalance_needs_scan_trans(struct btree_trans *, u64);
37 int bch2_set_rebalance_needs_scan(struct bch_fs *, u64 inum);
38 int bch2_set_fs_needs_rebalance(struct bch_fs *);
40 static inline void rebalance_wakeup(struct bch_fs *c)
42 struct task_struct *p;
45 p = rcu_dereference(c->rebalance.thread);
51 void bch2_rebalance_status_to_text(struct printbuf *, struct bch_fs *);
53 void bch2_rebalance_stop(struct bch_fs *);
54 int bch2_rebalance_start(struct bch_fs *);
55 void bch2_fs_rebalance_init(struct bch_fs *);
57 #endif /* _BCACHEFS_REBALANCE_H */