1 #ifndef _BCACHEFS_MOVE_H
2 #define _BCACHEFS_MOVE_H
7 enum moving_flag_bitnos {
8 MOVING_FLAG_BITNO_READ = 0,
9 MOVING_FLAG_BITNO_WRITE,
12 #define MOVING_FLAG_READ (1U << MOVING_FLAG_BITNO_READ)
13 #define MOVING_FLAG_WRITE (1U << MOVING_FLAG_BITNO_WRITE)
15 struct migrate_write {
19 struct bch_extent_ptr move_ptr;
20 struct bch_write_op op;
23 void bch2_migrate_write_init(struct bch_fs *, struct migrate_write *,
24 struct bch_devs_mask *, struct bkey_s_c,
25 const struct bch_extent_ptr *, unsigned);
27 #define SECTORS_IN_FLIGHT_PER_DEVICE 2048
29 struct moving_context {
30 /* Closure for waiting on all reads and writes to complete */
33 /* Number and types of errors reported */
37 /* Key and sector moves issued, updated from submission context */
41 /* Rate-limiter counting submitted reads */
42 struct bch_ratelimit *rate;
44 /* Try to avoid reading the following device */
45 struct bch_devs_mask avoid;
47 struct list_head reads;
50 unsigned max_sectors_in_flight;
51 atomic_t sectors_in_flight;
53 wait_queue_head_t wait;
57 struct list_head list;
60 struct moving_context *ctxt;
61 struct migrate_write write;
64 struct bch_read_bio rbio;
65 /* Must be last since it is variable size */
66 struct bio_vec bi_inline_vecs[0];
69 int bch2_data_move(struct bch_fs *, struct moving_context *,
70 struct bch_devs_mask *, struct bkey_s_c,
71 const struct bch_extent_ptr *);
73 int bch2_move_ctxt_wait(struct moving_context *);
74 void bch2_move_ctxt_wait_for_io(struct moving_context *);
76 void bch2_move_ctxt_exit(struct moving_context *);
77 void bch2_move_ctxt_init(struct moving_context *, struct bch_ratelimit *,
80 #endif /* _BCACHEFS_MOVE_H */