2017-03-16 22:18:50 -08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _BCACHEFS_MOVE_H
|
|
|
|
#define _BCACHEFS_MOVE_H
|
|
|
|
|
|
|
|
#include "btree_iter.h"
|
|
|
|
#include "buckets.h"
|
2022-06-13 19:07:19 -04:00
|
|
|
#include "data_update.h"
|
2017-03-16 22:18:50 -08:00
|
|
|
#include "move_types.h"
|
|
|
|
|
|
|
|
struct bch_read_bio;
|
|
|
|
|
2022-06-13 19:07:19 -04:00
|
|
|
struct moving_context {
|
2022-06-20 15:40:26 -04:00
|
|
|
struct bch_fs *c;
|
|
|
|
struct bch_ratelimit *rate;
|
2022-06-13 19:07:19 -04:00
|
|
|
struct bch_move_stats *stats;
|
2022-06-20 15:40:26 -04:00
|
|
|
struct write_point_specifier wp;
|
|
|
|
bool wait_on_copygc;
|
2017-03-16 22:18:50 -08:00
|
|
|
|
2022-06-20 15:40:26 -04:00
|
|
|
/* For waiting on outstanding reads and writes: */
|
|
|
|
struct closure cl;
|
2022-06-13 19:07:19 -04:00
|
|
|
struct list_head reads;
|
2017-03-16 22:18:50 -08:00
|
|
|
|
2022-06-13 19:07:19 -04:00
|
|
|
/* in flight sectors: */
|
|
|
|
atomic_t read_sectors;
|
|
|
|
atomic_t write_sectors;
|
2017-03-16 22:18:50 -08:00
|
|
|
|
2022-06-13 19:07:19 -04:00
|
|
|
wait_queue_head_t wait;
|
2017-03-16 22:18:50 -08:00
|
|
|
};
|
|
|
|
|
2022-06-13 19:17:45 -04:00
|
|
|
typedef bool (*move_pred_fn)(struct bch_fs *, void *, struct bkey_s_c,
|
2022-06-20 15:40:26 -04:00
|
|
|
struct bch_io_opts *, struct data_update_opts *);
|
|
|
|
|
|
|
|
void bch2_moving_ctxt_exit(struct moving_context *);
|
|
|
|
void bch2_moving_ctxt_init(struct moving_context *, struct bch_fs *,
|
|
|
|
struct bch_ratelimit *, struct bch_move_stats *,
|
|
|
|
struct write_point_specifier, bool);
|
2017-03-16 22:18:50 -08:00
|
|
|
|
2021-03-22 18:39:16 -04:00
|
|
|
int bch2_scan_old_btree_nodes(struct bch_fs *, struct bch_move_stats *);
|
|
|
|
|
2021-03-14 19:01:14 -04:00
|
|
|
int bch2_move_data(struct bch_fs *,
|
|
|
|
enum btree_id, struct bpos,
|
|
|
|
enum btree_id, struct bpos,
|
|
|
|
struct bch_ratelimit *,
|
2022-06-16 02:06:43 +12:00
|
|
|
struct bch_move_stats *,
|
2022-06-20 15:40:26 -04:00
|
|
|
struct write_point_specifier,
|
|
|
|
bool,
|
|
|
|
move_pred_fn, void *);
|
2017-03-16 22:18:50 -08:00
|
|
|
|
|
|
|
int bch2_data_job(struct bch_fs *,
|
|
|
|
struct bch_move_stats *,
|
|
|
|
struct bch_ioctl_data);
|
|
|
|
|
2022-11-13 20:01:42 -05:00
|
|
|
void bch2_move_stats_init(struct bch_move_stats *stats, char *name);
|
2021-07-23 13:57:19 -06:00
|
|
|
|
|
|
|
|
2017-03-16 22:18:50 -08:00
|
|
|
#endif /* _BCACHEFS_MOVE_H */
|