1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_MOVE_H
3 #define _BCACHEFS_MOVE_H
5 #include "btree_iter.h"
7 #include "data_update.h"
8 #include "move_types.h"
12 struct moving_context {
14 struct bch_ratelimit *rate;
15 struct bch_move_stats *stats;
16 struct write_point_specifier wp;
20 /* For waiting on outstanding reads and writes: */
22 struct list_head reads;
24 /* in flight sectors: */
25 atomic_t read_sectors;
26 atomic_t write_sectors;
28 wait_queue_head_t wait;
31 typedef bool (*move_pred_fn)(struct bch_fs *, void *, struct bkey_s_c,
32 struct bch_io_opts *, struct data_update_opts *);
34 void bch2_moving_ctxt_exit(struct moving_context *);
35 void bch2_moving_ctxt_init(struct moving_context *, struct bch_fs *,
36 struct bch_ratelimit *, struct bch_move_stats *,
37 struct write_point_specifier, bool);
39 int bch2_scan_old_btree_nodes(struct bch_fs *, struct bch_move_stats *);
41 int bch2_move_data(struct bch_fs *,
42 enum btree_id, struct bpos,
43 enum btree_id, struct bpos,
44 struct bch_ratelimit *,
45 struct bch_move_stats *,
46 struct write_point_specifier,
48 move_pred_fn, void *);
50 int __bch2_evacuate_bucket(struct moving_context *,
52 struct data_update_opts);
53 int bch2_evacuate_bucket(struct bch_fs *, struct bpos, int,
54 struct data_update_opts,
55 struct bch_ratelimit *,
56 struct bch_move_stats *,
57 struct write_point_specifier,
59 int bch2_data_job(struct bch_fs *,
60 struct bch_move_stats *,
61 struct bch_ioctl_data);
63 inline void bch_move_stats_init(struct bch_move_stats *stats,
67 #endif /* _BCACHEFS_MOVE_H */