1 /* SPDX-License-Identifier: GPL-2.0 */ 2 3 #ifndef _BCACHEFS_DATA_UPDATE_H 4 #define _BCACHEFS_DATA_UPDATE_H 5 6 #include "bkey_buf.h" 7 #include "io_read.h" 8 #include "io_write_types.h" 9 10 struct moving_context; 11 12 struct data_update_opts { 13 unsigned rewrite_ptrs; 14 unsigned kill_ptrs; 15 u16 target; 16 u8 extra_replicas; 17 unsigned btree_insert_flags; 18 unsigned write_flags; 19 20 int read_dev; 21 bool scrub; 22 }; 23 24 void bch2_data_update_opts_to_text(struct printbuf *, struct bch_fs *, 25 struct bch_io_opts *, struct data_update_opts *); 26 27 #define BCH_DATA_UPDATE_TYPES() \ 28 x(copygc, 0) \ 29 x(rebalance, 1) \ 30 x(promote, 2) 31 32 enum bch_data_update_types { 33 #define x(n, id) BCH_DATA_UPDATE_##n = id, 34 BCH_DATA_UPDATE_TYPES() 35 #undef x 36 }; 37 38 struct data_update { 39 enum bch_data_update_types type; 40 /* extent being updated: */ 41 bool read_done; 42 enum btree_id btree_id; 43 struct bkey_buf k; 44 struct data_update_opts data_opts; 45 struct moving_context *ctxt; 46 struct bch_move_stats *stats; 47 48 struct bch_read_bio rbio; 49 struct bch_write_op op; 50 struct bio_vec *bvecs; 51 }; 52 53 void bch2_data_update_to_text(struct printbuf *, struct data_update *); 54 void bch2_data_update_inflight_to_text(struct printbuf *, struct data_update *); 55 56 int bch2_data_update_index_update(struct bch_write_op *); 57 58 void bch2_data_update_read_done(struct data_update *); 59 60 int bch2_extent_drop_ptrs(struct btree_trans *, 61 struct btree_iter *, 62 struct bkey_s_c, 63 struct bch_io_opts *, 64 struct data_update_opts *); 65 66 int bch2_data_update_bios_init(struct data_update *, struct bch_fs *, 67 struct bch_io_opts *); 68 69 void bch2_data_update_exit(struct data_update *); 70 int bch2_data_update_init(struct btree_trans *, struct btree_iter *, 71 struct moving_context *, 72 struct data_update *, 73 struct write_point_specifier, 74 struct bch_io_opts *, struct data_update_opts, 75 enum btree_id, struct bkey_s_c); 76 void bch2_data_update_opts_normalize(struct bkey_s_c, struct data_update_opts *); 77 78 #endif /* _BCACHEFS_DATA_UPDATE_H */ 79