]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/move.h
Update bcachefs sources to 90d78c2461 bcachefs: Option parsing for io targets
[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
8 struct bch_read_bio;
9 struct moving_context;
10
11 enum data_cmd {
12         DATA_SKIP,
13         DATA_SCRUB,
14         DATA_ADD_REPLICAS,
15         DATA_REWRITE,
16         DATA_PROMOTE,
17 };
18
19 struct data_opts {
20         u16             target;
21         unsigned        rewrite_dev;
22         int             btree_insert_flags;
23 };
24
25 struct migrate_write {
26         enum data_cmd           data_cmd;
27         struct data_opts        data_opts;
28
29         unsigned                nr_ptrs_reserved;
30
31         struct moving_context   *ctxt;
32
33         /* what we read: */
34         struct bch_extent_ptr   ptr;
35         u64                     offset;
36
37         struct bch_write_op     op;
38 };
39
40 void bch2_migrate_read_done(struct migrate_write *, struct bch_read_bio *);
41 int bch2_migrate_write_init(struct bch_fs *, struct migrate_write *,
42                             struct write_point_specifier,
43                             struct bch_io_opts,
44                             enum data_cmd, struct data_opts,
45                             struct bkey_s_c);
46
47 typedef enum data_cmd (*move_pred_fn)(struct bch_fs *, void *,
48                                 enum bkey_type, struct bkey_s_c_extent,
49                                 struct bch_io_opts *, struct data_opts *);
50
51 struct bch_move_stats {
52         enum bch_data_type      data_type;
53         struct btree_iter       iter;
54
55         atomic64_t              keys_moved;
56         atomic64_t              sectors_moved;
57         atomic64_t              sectors_seen;
58         atomic64_t              sectors_raced;
59 };
60
61 int bch2_move_data(struct bch_fs *, struct bch_ratelimit *,
62                    struct write_point_specifier,
63                    struct bpos, struct bpos,
64                    move_pred_fn, void *,
65                    struct bch_move_stats *);
66
67 int bch2_data_job(struct bch_fs *,
68                   struct bch_move_stats *,
69                   struct bch_ioctl_data);
70
71 #endif /* _BCACHEFS_MOVE_H */