summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/rebalance.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-11-01 20:10:01 +0100
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 23:08:12 +0200
commit26609b619fa2301eb7eb5855a7005d99f8a07a73 (patch)
tree40c8e4ec363aad8ede4ffa4e12f7dffb31841a39 /fs/bcachefs/rebalance.c
parentbcachefs: Fix a btree iter usage error (diff)
downloadlinux-26609b619fa2301eb7eb5855a7005d99f8a07a73.tar.xz
linux-26609b619fa2301eb7eb5855a7005d99f8a07a73.zip
bcachefs: Make bkey types globally unique
this lets us get rid of a lot of extra switch statements - in a lot of places we dispatch on the btree node type, and then the key type, so this is a nice cleanup across a lot of code. Also improve the on disk format versioning stuff. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/rebalance.c')
-rw-r--r--fs/bcachefs/rebalance.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/fs/bcachefs/rebalance.c b/fs/bcachefs/rebalance.c
index 5d246c5b8186..eec74d4a5712 100644
--- a/fs/bcachefs/rebalance.c
+++ b/fs/bcachefs/rebalance.c
@@ -70,28 +70,34 @@ void bch2_rebalance_add_work(struct bch_fs *c, u64 sectors)
}
static enum data_cmd rebalance_pred(struct bch_fs *c, void *arg,
- enum bkey_type type,
- struct bkey_s_c_extent e,
+ struct bkey_s_c k,
struct bch_io_opts *io_opts,
struct data_opts *data_opts)
{
- const union bch_extent_entry *entry;
- struct extent_ptr_decoded p;
+ switch (k.k->type) {
+ case KEY_TYPE_extent: {
+ struct bkey_s_c_extent e = bkey_s_c_to_extent(k);
+ const union bch_extent_entry *entry;
+ struct extent_ptr_decoded p;
- /* Make sure we have room to add a new pointer: */
- if (bkey_val_u64s(e.k) + BKEY_EXTENT_PTR_U64s_MAX >
- BKEY_EXTENT_VAL_U64s_MAX)
- return DATA_SKIP;
+ /* Make sure we have room to add a new pointer: */
+ if (bkey_val_u64s(e.k) + BKEY_EXTENT_PTR_U64s_MAX >
+ BKEY_EXTENT_VAL_U64s_MAX)
+ return DATA_SKIP;
- extent_for_each_ptr_decode(e, p, entry)
- if (rebalance_ptr_pred(c, p, io_opts))
- goto found;
+ extent_for_each_ptr_decode(e, p, entry)
+ if (rebalance_ptr_pred(c, p, io_opts))
+ goto found;
- return DATA_SKIP;
+ return DATA_SKIP;
found:
- data_opts->target = io_opts->background_target;
- data_opts->btree_insert_flags = 0;
- return DATA_ADD_REPLICAS;
+ data_opts->target = io_opts->background_target;
+ data_opts->btree_insert_flags = 0;
+ return DATA_ADD_REPLICAS;
+ }
+ default:
+ return DATA_SKIP;
+ }
}
struct rebalance_work {