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