summaryrefslogtreecommitdiff
path: root/fs/bcachefs/rebalance.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs/rebalance.h')
-rw-r--r--fs/bcachefs/rebalance.h50
1 files changed, 14 insertions, 36 deletions
diff --git a/fs/bcachefs/rebalance.h b/fs/bcachefs/rebalance.h
index f40f670af046..24bafa42f070 100644
--- a/fs/bcachefs/rebalance.h
+++ b/fs/bcachefs/rebalance.h
@@ -7,14 +7,10 @@
#include "opts.h"
#include "rebalance_types.h"
-int bch2_extent_rebalance_validate(struct bch_fs *, struct bkey_s_c,
- struct bkey_validate_context,
- const struct bch_extent_rebalance *);
-
static inline struct bch_extent_rebalance io_opts_to_rebalance_opts(struct bch_fs *c,
struct bch_inode_opts *opts)
{
- return (struct bch_extent_rebalance) {
+ struct bch_extent_rebalance r = {
.type = BIT(BCH_EXTENT_ENTRY_rebalance),
#define x(_name) \
._name = opts->_name, \
@@ -22,36 +18,22 @@ static inline struct bch_extent_rebalance io_opts_to_rebalance_opts(struct bch_f
BCH_REBALANCE_OPTS()
#undef x
};
+
+ if (r.background_target &&
+ !bch2_target_accepts_data(c, BCH_DATA_user, r.background_target))
+ r.background_target = 0;
+
+ return r;
};
void bch2_extent_rebalance_to_text(struct printbuf *, struct bch_fs *,
const struct bch_extent_rebalance *);
-const struct bch_extent_rebalance *bch2_bkey_rebalance_opts(struct bkey_s_c);
-
-static inline int bch2_bkey_needs_rb(struct bkey_s_c k)
-{
- const struct bch_extent_rebalance *r = bch2_bkey_rebalance_opts(k);
- return r ? r->need_rb : 0;
-}
-
-int __bch2_trigger_extent_rebalance(struct btree_trans *,
- struct bkey_s_c, struct bkey_s_c,
- unsigned, unsigned,
- enum btree_iter_update_trigger_flags);
+int bch2_trigger_extent_rebalance(struct btree_trans *,
+ struct bkey_s_c, struct bkey_s_c,
+ enum btree_iter_update_trigger_flags);
-static inline int bch2_trigger_extent_rebalance(struct btree_trans *trans,
- struct bkey_s_c old, struct bkey_s_c new,
- enum btree_iter_update_trigger_flags flags)
-{
- unsigned old_r = bch2_bkey_needs_rb(old);
- unsigned new_r = bch2_bkey_needs_rb(new);
-
- return old_r != new_r ||
- (old.k->size != new.k->size && (old_r|new_r))
- ? __bch2_trigger_extent_rebalance(trans, old, new, old_r, new_r, flags)
- : 0;
-}
+u64 bch2_bkey_sectors_need_rebalance(struct bch_fs *, struct bkey_s_c);
enum set_needs_rebalance_ctx {
SET_NEEDS_REBALANCE_opt_change,
@@ -60,6 +42,9 @@ enum set_needs_rebalance_ctx {
SET_NEEDS_REBALANCE_other,
};
+int bch2_bkey_set_needs_rebalance(struct bch_fs *, struct bch_inode_opts *,
+ struct bkey_i *, enum set_needs_rebalance_ctx, u32);
+
/* Inodes in different snapshots may have different IO options: */
struct snapshot_io_opts_entry {
u32 snapshot;
@@ -68,9 +53,6 @@ struct snapshot_io_opts_entry {
struct per_snapshot_io_opts {
u64 cur_inum;
- bool fs_scan_cookie;
- bool inum_scan_cookie;
-
struct bch_inode_opts fs_io_opts;
DARRAY(struct snapshot_io_opts_entry) d;
};
@@ -86,10 +68,6 @@ static inline void per_snapshot_io_opts_exit(struct per_snapshot_io_opts *io_opt
darray_exit(&io_opts->d);
}
-int bch2_bkey_set_needs_rebalance(struct btree_trans *,
- struct per_snapshot_io_opts *, struct bch_inode_opts *,
- struct bkey_i *, enum set_needs_rebalance_ctx, u32);
-
struct bch_inode_opts *bch2_extent_get_apply_io_opts(struct btree_trans *,
struct per_snapshot_io_opts *, struct bpos,
struct btree_iter *, struct bkey_s_c,