mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 04:06:26 +00:00
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>
This commit is contained in:
parent
25be2e5d4a
commit
179e3434fa
@ -351,7 +351,8 @@ static inline void bkey_init(struct bkey *k)
|
||||
x(subvolume, 21) \
|
||||
x(snapshot, 22) \
|
||||
x(inode_v2, 23) \
|
||||
x(alloc_v3, 24)
|
||||
x(alloc_v3, 24) \
|
||||
x(set, 25)
|
||||
|
||||
enum bch_bkey_type {
|
||||
#define x(name, nr) KEY_TYPE_##name = nr,
|
||||
@ -381,6 +382,10 @@ struct bch_hash_whiteout {
|
||||
struct bch_val v;
|
||||
};
|
||||
|
||||
struct bch_set {
|
||||
struct bch_val v;
|
||||
};
|
||||
|
||||
/* Extents */
|
||||
|
||||
/*
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user