xref: /linux/fs/bcachefs/data_update.h (revision 4a4b30ea80d8cb5e8c4c62bb86201f4ea0d9b030)
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  struct data_update {
28  	/* extent being updated: */
29  	bool			read_done;
30  	enum btree_id		btree_id;
31  	struct bkey_buf		k;
32  	struct data_update_opts	data_opts;
33  	struct moving_context	*ctxt;
34  	struct bch_move_stats	*stats;
35  
36  	struct bch_read_bio	rbio;
37  	struct bch_write_op	op;
38  	struct bio_vec		*bvecs;
39  };
40  
41  void bch2_data_update_to_text(struct printbuf *, struct data_update *);
42  void bch2_data_update_inflight_to_text(struct printbuf *, struct data_update *);
43  
44  int bch2_data_update_index_update(struct bch_write_op *);
45  
46  void bch2_data_update_read_done(struct data_update *);
47  
48  int bch2_extent_drop_ptrs(struct btree_trans *,
49  			  struct btree_iter *,
50  			  struct bkey_s_c,
51  			  struct bch_io_opts *,
52  			  struct data_update_opts *);
53  
54  int bch2_data_update_bios_init(struct data_update *, struct bch_fs *,
55  			       struct bch_io_opts *);
56  
57  void bch2_data_update_exit(struct data_update *);
58  int bch2_data_update_init(struct btree_trans *, struct btree_iter *,
59  			  struct moving_context *,
60  			  struct data_update *,
61  			  struct write_point_specifier,
62  			  struct bch_io_opts *, struct data_update_opts,
63  			  enum btree_id, struct bkey_s_c);
64  void bch2_data_update_opts_normalize(struct bkey_s_c, struct data_update_opts *);
65  
66  #endif /* _BCACHEFS_DATA_UPDATE_H */
67