2022-06-13 19:07:19 -04:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
|
|
|
|
#ifndef _BCACHEFS_DATA_UPDATE_H
|
|
|
|
#define _BCACHEFS_DATA_UPDATE_H
|
|
|
|
|
2022-06-13 19:17:45 -04:00
|
|
|
#include "bkey_buf.h"
|
2025-01-15 18:53:55 -05:00
|
|
|
#include "io_read.h"
|
2023-09-10 18:05:17 -04:00
|
|
|
#include "io_write_types.h"
|
2022-06-13 19:07:19 -04:00
|
|
|
|
2022-06-13 19:17:45 -04:00
|
|
|
struct moving_context;
|
2022-06-13 19:07:19 -04:00
|
|
|
|
2022-06-13 19:17:45 -04:00
|
|
|
struct data_update_opts {
|
|
|
|
unsigned rewrite_ptrs;
|
2022-10-09 03:32:17 -04:00
|
|
|
unsigned kill_ptrs;
|
2022-06-13 19:07:19 -04:00
|
|
|
u16 target;
|
2022-06-13 19:17:45 -04:00
|
|
|
u8 extra_replicas;
|
|
|
|
unsigned btree_insert_flags;
|
|
|
|
unsigned write_flags;
|
2024-12-28 19:59:55 -05:00
|
|
|
|
|
|
|
int read_dev;
|
|
|
|
bool scrub;
|
2022-06-13 19:07:19 -04:00
|
|
|
};
|
|
|
|
|
2024-07-03 13:25:13 -04:00
|
|
|
void bch2_data_update_opts_to_text(struct printbuf *, struct bch_fs *,
|
|
|
|
struct bch_io_opts *, struct data_update_opts *);
|
|
|
|
|
2025-03-30 16:57:21 -04:00
|
|
|
#define BCH_DATA_UPDATE_TYPES() \
|
|
|
|
x(copygc, 0) \
|
|
|
|
x(rebalance, 1) \
|
|
|
|
x(promote, 2)
|
|
|
|
|
|
|
|
enum bch_data_update_types {
|
|
|
|
#define x(n, id) BCH_DATA_UPDATE_##n = id,
|
|
|
|
BCH_DATA_UPDATE_TYPES()
|
|
|
|
#undef x
|
|
|
|
};
|
|
|
|
|
2022-06-13 19:07:19 -04:00
|
|
|
struct data_update {
|
2025-03-30 16:57:21 -04:00
|
|
|
enum bch_data_update_types type;
|
2022-06-13 19:17:45 -04:00
|
|
|
/* extent being updated: */
|
2024-12-31 18:16:17 -05:00
|
|
|
bool read_done;
|
2022-06-13 19:07:19 -04:00
|
|
|
enum btree_id btree_id;
|
2022-06-13 19:17:45 -04:00
|
|
|
struct bkey_buf k;
|
|
|
|
struct data_update_opts data_opts;
|
2022-06-13 19:07:19 -04:00
|
|
|
struct moving_context *ctxt;
|
2023-10-23 15:36:45 -04:00
|
|
|
struct bch_move_stats *stats;
|
2025-01-15 18:53:55 -05:00
|
|
|
|
|
|
|
struct bch_read_bio rbio;
|
2022-06-13 19:07:19 -04:00
|
|
|
struct bch_write_op op;
|
2025-01-16 00:40:43 -05:00
|
|
|
struct bio_vec *bvecs;
|
2022-06-13 19:07:19 -04:00
|
|
|
};
|
|
|
|
|
2025-04-21 13:02:51 -04:00
|
|
|
struct promote_op {
|
|
|
|
struct rcu_head rcu;
|
|
|
|
u64 start_time;
|
|
|
|
#ifdef CONFIG_BCACHEFS_ASYNC_OBJECT_LISTS
|
|
|
|
unsigned list_idx;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct rhash_head hash;
|
|
|
|
struct bpos pos;
|
|
|
|
|
|
|
|
struct work_struct work;
|
|
|
|
struct data_update write;
|
|
|
|
struct bio_vec bi_inline_vecs[]; /* must be last */
|
|
|
|
};
|
|
|
|
|
2024-07-03 13:25:13 -04:00
|
|
|
void bch2_data_update_to_text(struct printbuf *, struct data_update *);
|
2024-12-31 18:16:17 -05:00
|
|
|
void bch2_data_update_inflight_to_text(struct printbuf *, struct data_update *);
|
2024-07-03 13:25:13 -04:00
|
|
|
|
2022-06-13 19:07:19 -04:00
|
|
|
int bch2_data_update_index_update(struct bch_write_op *);
|
|
|
|
|
2025-01-16 00:40:43 -05:00
|
|
|
void bch2_data_update_read_done(struct data_update *);
|
2022-06-13 19:17:45 -04:00
|
|
|
|
2023-11-24 21:51:45 -05:00
|
|
|
int bch2_extent_drop_ptrs(struct btree_trans *,
|
|
|
|
struct btree_iter *,
|
|
|
|
struct bkey_s_c,
|
2024-10-20 20:02:09 -04:00
|
|
|
struct bch_io_opts *,
|
|
|
|
struct data_update_opts *);
|
2023-11-24 21:51:45 -05:00
|
|
|
|
2024-12-28 19:59:55 -05:00
|
|
|
int bch2_data_update_bios_init(struct data_update *, struct bch_fs *,
|
|
|
|
struct bch_io_opts *);
|
|
|
|
|
2022-06-13 19:17:45 -04:00
|
|
|
void bch2_data_update_exit(struct data_update *);
|
2023-11-24 21:51:45 -05:00
|
|
|
int bch2_data_update_init(struct btree_trans *, struct btree_iter *,
|
|
|
|
struct moving_context *,
|
2023-01-02 17:53:02 -05:00
|
|
|
struct data_update *,
|
2022-06-13 19:07:19 -04:00
|
|
|
struct write_point_specifier,
|
2024-12-28 19:59:55 -05:00
|
|
|
struct bch_io_opts *, struct data_update_opts,
|
2022-06-13 19:07:19 -04:00
|
|
|
enum btree_id, struct bkey_s_c);
|
2022-10-09 03:32:17 -04:00
|
|
|
void bch2_data_update_opts_normalize(struct bkey_s_c, struct data_update_opts *);
|
2022-06-13 19:07:19 -04:00
|
|
|
|
|
|
|
#endif /* _BCACHEFS_DATA_UPDATE_H */
|