summaryrefslogtreecommitdiff
path: root/fs/bcachefs/movinggc.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-11-01 15:10:01 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:12 -0400
commit26609b619fa2301eb7eb5855a7005d99f8a07a73 (patch)
tree40c8e4ec363aad8ede4ffa4e12f7dffb31841a39 /fs/bcachefs/movinggc.c
parent01a0108f0139a2f6dbace54dd5d592d2d76415c1 (diff)
downloadlwn-26609b619fa2301eb7eb5855a7005d99f8a07a73.tar.gz
lwn-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/movinggc.c')
-rw-r--r--fs/bcachefs/movinggc.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c
index 80577661e008..4bf4cc33dbb1 100644
--- a/fs/bcachefs/movinggc.c
+++ b/fs/bcachefs/movinggc.c
@@ -66,36 +66,42 @@ static int bucket_offset_cmp(const void *_l, const void *_r, size_t size)
}
static bool __copygc_pred(struct bch_dev *ca,
- struct bkey_s_c_extent e)
+ struct bkey_s_c k)
{
copygc_heap *h = &ca->copygc_heap;
- const struct bch_extent_ptr *ptr =
- bch2_extent_has_device(e, ca->dev_idx);
- if (ptr) {
- struct copygc_heap_entry search = { .offset = ptr->offset };
+ switch (k.k->type) {
+ case KEY_TYPE_extent: {
+ struct bkey_s_c_extent e = bkey_s_c_to_extent(k);
+ const struct bch_extent_ptr *ptr =
+ bch2_extent_has_device(e, ca->dev_idx);
- ssize_t i = eytzinger0_find_le(h->data, h->used,
- sizeof(h->data[0]),
- bucket_offset_cmp, &search);
+ if (ptr) {
+ struct copygc_heap_entry search = { .offset = ptr->offset };
- return (i >= 0 &&
- ptr->offset < h->data[i].offset + ca->mi.bucket_size &&
- ptr->gen == h->data[i].gen);
+ ssize_t i = eytzinger0_find_le(h->data, h->used,
+ sizeof(h->data[0]),
+ bucket_offset_cmp, &search);
+
+ return (i >= 0 &&
+ ptr->offset < h->data[i].offset + ca->mi.bucket_size &&
+ ptr->gen == h->data[i].gen);
+ }
+ break;
+ }
}
return false;
}
static enum data_cmd copygc_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)
{
struct bch_dev *ca = arg;
- if (!__copygc_pred(ca, e))
+ if (!__copygc_pred(ca, k))
return DATA_SKIP;
data_opts->target = dev_to_target(ca->dev_idx);