xref: /linux/fs/bcachefs/rebalance.h (revision 1cbfb828e05171ca2dd77b5988d068e6872480fe)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_REBALANCE_H
3 #define _BCACHEFS_REBALANCE_H
4 
5 #include "compress.h"
6 #include "disk_groups.h"
7 #include "rebalance_types.h"
8 
9 u64 bch2_bkey_sectors_need_rebalance(struct bch_fs *, struct bkey_s_c);
10 int bch2_bkey_set_needs_rebalance(struct bch_fs *, struct bch_io_opts *, struct bkey_i *);
11 int bch2_get_update_rebalance_opts(struct btree_trans *,
12 				   struct bch_io_opts *,
13 				   struct btree_iter *,
14 				   struct bkey_s_c);
15 
16 int bch2_set_rebalance_needs_scan_trans(struct btree_trans *, u64);
17 int bch2_set_rebalance_needs_scan(struct bch_fs *, u64 inum);
18 int bch2_set_fs_needs_rebalance(struct bch_fs *);
19 
20 static inline void rebalance_wakeup(struct bch_fs *c)
21 {
22 	struct task_struct *p;
23 
24 	rcu_read_lock();
25 	p = rcu_dereference(c->rebalance.thread);
26 	if (p)
27 		wake_up_process(p);
28 	rcu_read_unlock();
29 }
30 
31 void bch2_rebalance_status_to_text(struct printbuf *, struct bch_fs *);
32 
33 void bch2_rebalance_stop(struct bch_fs *);
34 int bch2_rebalance_start(struct bch_fs *);
35 void bch2_fs_rebalance_init(struct bch_fs *);
36 
37 #endif /* _BCACHEFS_REBALANCE_H */
38