6 #include "move_types.h"
8 enum moving_flag_bitnos {
9 MOVING_FLAG_BITNO_READ = 0,
10 MOVING_FLAG_BITNO_WRITE,
13 #define MOVING_FLAG_READ (1U << MOVING_FLAG_BITNO_READ)
14 #define MOVING_FLAG_WRITE (1U << MOVING_FLAG_BITNO_WRITE)
16 struct migrate_write {
20 struct bch_extent_ptr move_ptr;
21 struct bch_write_op op;
22 struct bch_write_bio wbio;
25 void bch2_migrate_write_init(struct bch_fs *,
26 struct migrate_write *,
29 const struct bch_extent_ptr *,
32 #define SECTORS_IN_FLIGHT_PER_DEVICE 2048
34 struct moving_context {
35 /* Closure for waiting on all reads and writes to complete */
38 /* Number and types of errors reported */
42 /* Key and sector moves issued, updated from submission context */
46 /* Rate-limiter counting submitted reads */
47 struct bch_ratelimit *rate;
49 /* Try to avoid reading the following device */
50 struct bch_dev *avoid;
52 struct list_head reads;
55 unsigned max_sectors_in_flight;
56 atomic_t sectors_in_flight;
58 wait_queue_head_t wait;
62 struct list_head list;
65 struct moving_context *ctxt;
66 struct migrate_write write;
69 struct bch_read_bio rbio;
70 /* Must be last since it is variable size */
71 struct bio_vec bi_inline_vecs[0];
74 int bch2_data_move(struct bch_fs *,
75 struct moving_context *,
78 const struct bch_extent_ptr *);
80 int bch2_move_ctxt_wait(struct moving_context *);
81 void bch2_move_ctxt_wait_for_io(struct moving_context *);
83 void bch2_move_ctxt_exit(struct moving_context *);
84 void bch2_move_ctxt_init(struct moving_context *, struct bch_ratelimit *,
87 #endif /* _BCACHE_MOVE_H */