Commit | Line | Data |
---|---|---|
1c6fdbd8 KO |
1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | #ifndef _BCACHEFS_REBALANCE_H | |
3 | #define _BCACHEFS_REBALANCE_H | |
4 | ||
a652c565 KO |
5 | #include "compress.h" |
6 | #include "disk_groups.h" | |
4be214c2 | 7 | #include "opts.h" |
1c6fdbd8 KO |
8 | #include "rebalance_types.h" |
9 | ||
4be214c2 KO |
10 | static inline struct bch_extent_rebalance io_opts_to_rebalance_opts(struct bch_fs *c, |
11 | struct bch_io_opts *opts) | |
12 | { | |
13 | struct bch_extent_rebalance r = { | |
14 | .type = BIT(BCH_EXTENT_ENTRY_rebalance), | |
15 | #define x(_name) \ | |
16 | ._name = opts->_name, \ | |
17 | ._name##_from_inode = opts->_name##_from_inode, | |
18 | BCH_REBALANCE_OPTS() | |
19 | #undef x | |
20 | }; | |
21 | ||
22 | if (r.background_target && | |
23 | !bch2_target_accepts_data(c, BCH_DATA_user, r.background_target)) | |
24 | r.background_target = 0; | |
25 | ||
26 | return r; | |
27 | }; | |
28 | ||
161d1383 KO |
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 *, | |
32 | struct bch_io_opts *, | |
33 | struct btree_iter *, | |
34 | struct bkey_s_c); | |
a652c565 | 35 | |
4ae6bbb5 | 36 | int bch2_set_rebalance_needs_scan_trans(struct btree_trans *, u64); |
fb3f57bb KO |
37 | int bch2_set_rebalance_needs_scan(struct bch_fs *, u64 inum); |
38 | int bch2_set_fs_needs_rebalance(struct bch_fs *); | |
39 | ||
10e42b6f | 40 | static inline void bch2_rebalance_wakeup(struct bch_fs *c) |
1c6fdbd8 | 41 | { |
9e2c3c2e KO |
42 | c->rebalance.kick++; |
43 | guard(rcu)(); | |
44 | struct task_struct *p = rcu_dereference(c->rebalance.thread); | |
1c6fdbd8 KO |
45 | if (p) |
46 | wake_up_process(p); | |
1c6fdbd8 KO |
47 | } |
48 | ||
fb3f57bb | 49 | void bch2_rebalance_status_to_text(struct printbuf *, struct bch_fs *); |
1c6fdbd8 KO |
50 | |
51 | void bch2_rebalance_stop(struct bch_fs *); | |
52 | int bch2_rebalance_start(struct bch_fs *); | |
96fc7d8a KO |
53 | |
54 | void bch2_fs_rebalance_exit(struct bch_fs *); | |
55 | int bch2_fs_rebalance_init(struct bch_fs *); | |
1c6fdbd8 | 56 | |
834f9475 KO |
57 | int bch2_check_rebalance_work(struct bch_fs *); |
58 | ||
1c6fdbd8 | 59 | #endif /* _BCACHEFS_REBALANCE_H */ |