Merge tag 'mm-hotfixes-stable-2025-07-11-16-16' of git://git.kernel.org/pub/scm/linux...
[linux-block.git] / fs / bcachefs / rebalance.h
... / ...
CommitLineData
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 "opts.h"
8#include "rebalance_types.h"
9
10static 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
29u64 bch2_bkey_sectors_need_rebalance(struct bch_fs *, struct bkey_s_c);
30int bch2_bkey_set_needs_rebalance(struct bch_fs *, struct bch_io_opts *, struct bkey_i *);
31int bch2_get_update_rebalance_opts(struct btree_trans *,
32 struct bch_io_opts *,
33 struct btree_iter *,
34 struct bkey_s_c);
35
36int bch2_set_rebalance_needs_scan_trans(struct btree_trans *, u64);
37int bch2_set_rebalance_needs_scan(struct bch_fs *, u64 inum);
38int bch2_set_fs_needs_rebalance(struct bch_fs *);
39
40static inline void bch2_rebalance_wakeup(struct bch_fs *c)
41{
42 c->rebalance.kick++;
43 guard(rcu)();
44 struct task_struct *p = rcu_dereference(c->rebalance.thread);
45 if (p)
46 wake_up_process(p);
47}
48
49void bch2_rebalance_status_to_text(struct printbuf *, struct bch_fs *);
50
51void bch2_rebalance_stop(struct bch_fs *);
52int bch2_rebalance_start(struct bch_fs *);
53
54void bch2_fs_rebalance_exit(struct bch_fs *);
55int bch2_fs_rebalance_init(struct bch_fs *);
56
57int bch2_check_rebalance_work(struct bch_fs *);
58
59#endif /* _BCACHEFS_REBALANCE_H */