-#ifndef _BCACHE_MOVE_H
-#define _BCACHE_MOVE_H
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _BCACHEFS_MOVE_H
+#define _BCACHEFS_MOVE_H
+#include "btree_iter.h"
#include "buckets.h"
#include "io_types.h"
#include "move_types.h"
-enum moving_flag_bitnos {
- MOVING_FLAG_BITNO_READ = 0,
- MOVING_FLAG_BITNO_WRITE,
-};
-
-#define MOVING_FLAG_READ (1U << MOVING_FLAG_BITNO_READ)
-#define MOVING_FLAG_WRITE (1U << MOVING_FLAG_BITNO_WRITE)
+struct bch_read_bio;
+struct moving_context;
-struct migrate_write {
- BKEY_PADDED(key);
- bool promote;
- bool move;
- struct bch_extent_ptr move_ptr;
- struct bch_write_op op;
+enum data_cmd {
+ DATA_SKIP,
+ DATA_SCRUB,
+ DATA_ADD_REPLICAS,
+ DATA_REWRITE,
+ DATA_PROMOTE,
};
-void bch2_migrate_write_init(struct bch_fs *,
- struct migrate_write *,
- struct write_point *,
- struct bkey_s_c,
- const struct bch_extent_ptr *,
- unsigned);
-
-#define SECTORS_IN_FLIGHT_PER_DEVICE 2048
-
-struct moving_context {
- /* Closure for waiting on all reads and writes to complete */
- struct closure cl;
-
- /* Number and types of errors reported */
- atomic_t error_count;
- atomic_t error_flags;
-
- /* Key and sector moves issued, updated from submission context */
- u64 keys_moved;
- u64 sectors_moved;
+struct data_opts {
+ u16 target;
+ unsigned rewrite_dev;
+ int btree_insert_flags;
+};
- /* Rate-limiter counting submitted reads */
- struct bch_ratelimit *rate;
+struct migrate_write {
+ enum btree_id btree_id;
+ enum data_cmd data_cmd;
+ struct data_opts data_opts;
- /* Try to avoid reading the following device */
- struct bch_dev *avoid;
+ unsigned nr_ptrs_reserved;
- struct list_head reads;
+ struct moving_context *ctxt;
- /* Configuration */
- unsigned max_sectors_in_flight;
- atomic_t sectors_in_flight;
+ /* what we read: */
+ struct bch_extent_ptr ptr;
+ u64 offset;
- wait_queue_head_t wait;
+ struct bch_write_op op;
};
-struct moving_io {
- struct list_head list;
- struct rb_node node;
- struct closure cl;
- struct moving_context *ctxt;
- struct migrate_write write;
- bool read_completed;
-
- struct bch_read_bio rbio;
- /* Must be last since it is variable size */
- struct bio_vec bi_inline_vecs[0];
-};
+void bch2_migrate_read_done(struct migrate_write *, struct bch_read_bio *);
+int bch2_migrate_write_init(struct bch_fs *, struct migrate_write *,
+ struct write_point_specifier,
+ struct bch_io_opts,
+ enum data_cmd, struct data_opts,
+ enum btree_id, struct bkey_s_c);
-int bch2_data_move(struct bch_fs *,
- struct moving_context *,
- struct write_point *,
- struct bkey_s_c,
- const struct bch_extent_ptr *);
+typedef enum data_cmd (*move_pred_fn)(struct bch_fs *, void *,
+ struct bkey_s_c,
+ struct bch_io_opts *, struct data_opts *);
-int bch2_move_ctxt_wait(struct moving_context *);
-void bch2_move_ctxt_wait_for_io(struct moving_context *);
+int bch2_move_data(struct bch_fs *, struct bch_ratelimit *,
+ struct write_point_specifier,
+ struct bpos, struct bpos,
+ move_pred_fn, void *,
+ struct bch_move_stats *);
-void bch2_move_ctxt_exit(struct moving_context *);
-void bch2_move_ctxt_init(struct moving_context *, struct bch_ratelimit *,
- unsigned);
+int bch2_data_job(struct bch_fs *,
+ struct bch_move_stats *,
+ struct bch_ioctl_data);
-#endif /* _BCACHE_MOVE_H */
+#endif /* _BCACHEFS_MOVE_H */