Commit 179e3434 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: KEY_TYPE_set

A new empty key type, to be used when using a btree as a set.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 25be2e5d
...@@ -351,7 +351,8 @@ static inline void bkey_init(struct bkey *k) ...@@ -351,7 +351,8 @@ static inline void bkey_init(struct bkey *k)
x(subvolume, 21) \ x(subvolume, 21) \
x(snapshot, 22) \ x(snapshot, 22) \
x(inode_v2, 23) \ x(inode_v2, 23) \
x(alloc_v3, 24) x(alloc_v3, 24) \
x(set, 25)
enum bch_bkey_type { enum bch_bkey_type {
#define x(name, nr) KEY_TYPE_##name = nr, #define x(name, nr) KEY_TYPE_##name = nr,
...@@ -381,6 +382,10 @@ struct bch_hash_whiteout { ...@@ -381,6 +382,10 @@ struct bch_hash_whiteout {
struct bch_val v; struct bch_val v;
}; };
struct bch_set {
struct bch_val v;
};
/* Extents */ /* Extents */
/* /*
......
...@@ -85,6 +85,24 @@ static void key_type_inline_data_to_text(struct printbuf *out, struct bch_fs *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, \ .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[] = { const struct bkey_ops bch2_bkey_ops[] = {
#define x(name, nr) [KEY_TYPE_##name] = bch2_bkey_ops_##name, #define x(name, nr) [KEY_TYPE_##name] = bch2_bkey_ops_##name,
BCH_BKEY_TYPES() BCH_BKEY_TYPES()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment