]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/move.h
Update bcachefs sources to 62de7539dc bcachefs: Make bkey types globally unique
[bcachefs-tools-debian] / libbcachefs / move.h
1 #ifndef _BCACHEFS_MOVE_H
2 #define _BCACHEFS_MOVE_H
3
4 #include "btree_iter.h"
5 #include "buckets.h"
6 #include "io_types.h"
7 #include "move_types.h"
8
9 struct bch_read_bio;
10 struct moving_context;
11
12 enum data_cmd {
13         DATA_SKIP,
14         DATA_SCRUB,
15         DATA_ADD_REPLICAS,
16         DATA_REWRITE,
17         DATA_PROMOTE,
18 };
19
20 struct data_opts {
21         u16             target;
22         unsigned        rewrite_dev;
23         int             btree_insert_flags;
24 };
25
26 struct migrate_write {
27         enum data_cmd           data_cmd;
28         struct data_opts        data_opts;
29
30         unsigned                nr_ptrs_reserved;
31
32         struct moving_context   *ctxt;
33
34         /* what we read: */
35         struct bch_extent_ptr   ptr;
36         u64                     offset;
37
38         struct bch_write_op     op;
39 };
40
41 void bch2_migrate_read_done(struct migrate_write *, struct bch_read_bio *);
42 int bch2_migrate_write_init(struct bch_fs *, struct migrate_write *,
43                             struct write_point_specifier,
44                             struct bch_io_opts,
45                             enum data_cmd, struct data_opts,
46                             struct bkey_s_c);
47
48 typedef enum data_cmd (*move_pred_fn)(struct bch_fs *, void *,
49                                 struct bkey_s_c,
50                                 struct bch_io_opts *, struct data_opts *);
51
52 int bch2_move_data(struct bch_fs *, struct bch_ratelimit *,
53                    struct write_point_specifier,
54                    struct bpos, struct bpos,
55                    move_pred_fn, void *,
56                    struct bch_move_stats *);
57
58 int bch2_data_job(struct bch_fs *,
59                   struct bch_move_stats *,
60                   struct bch_ioctl_data);
61
62 #endif /* _BCACHEFS_MOVE_H */