diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-01-06 06:13:13 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:29 +0300 |
commit | 179e3434fac14a100bad2edba4fd401bffb67802 (patch) | |
tree | 9b1c82c1948ff18b046dffa6d41464eb36c61545 /fs/bcachefs/bkey_methods.c | |
parent | 25be2e5d4a051ff2408c7ab007394e96798cf559 (diff) | |
download | linux-179e3434fac14a100bad2edba4fd401bffb67802.tar.xz |
bcachefs: KEY_TYPE_set
A new empty key type, to be used when using a btree as a set.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/bkey_methods.c')
-rw-r--r-- | fs/bcachefs/bkey_methods.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/bcachefs/bkey_methods.c b/fs/bcachefs/bkey_methods.c index f11b6d9f08d6..d938ee826c75 100644 --- a/fs/bcachefs/bkey_methods.c +++ b/fs/bcachefs/bkey_methods.c @@ -85,6 +85,24 @@ static void key_type_inline_data_to_text(struct printbuf *out, struct bch_fs *c, .val_to_text = key_type_inline_data_to_text, \ } +static const char *key_type_set_invalid(const struct bch_fs *c, struct bkey_s_c k) +{ + if (bkey_val_bytes(k.k)) + return "nonempty value"; + return NULL; +} + +static bool key_type_set_merge(struct bch_fs *c, struct bkey_s l, struct bkey_s_c r) +{ + bch2_key_resize(l.k, l.k->size + r.k->size); + return true; +} + +#define bch2_bkey_ops_set (struct bkey_ops) { \ + .key_invalid = key_type_set_invalid, \ + .key_merge = key_type_set_merge, \ +} + const struct bkey_ops bch2_bkey_ops[] = { #define x(name, nr) [KEY_TYPE_##name] = bch2_bkey_ops_##name, BCH_BKEY_TYPES() |