From ad44bdc351faeacb9b7294f1689ac76babf379ad Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sat, 9 Nov 2019 23:50:52 -0500 Subject: bcachefs: bkey noops For upcoming inline data extents, we're going to need to be able to shorten the value of existing bkeys in the btree - and to make that work we're going to be able to need to pad out the space the value previously took up with something. This patch changes the various code that iterates over bkeys to handle k->u64s == 0 as meaning "skip the next 8 bytes". Signed-off-by: Kent Overstreet Signed-off-by: Kent Overstreet --- fs/bcachefs/bset.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'fs/bcachefs/bset.h') diff --git a/fs/bcachefs/bset.h b/fs/bcachefs/bset.h index 3f5b7378a0a9..0e9bd8022d35 100644 --- a/fs/bcachefs/bset.h +++ b/fs/bcachefs/bset.h @@ -284,9 +284,14 @@ static inline struct bkey_s __bkey_disassemble(struct btree *b, return (struct bkey_s) { .k = u, .v = bkeyp_val(&b->format, k), }; } -#define for_each_bset(_b, _t) \ +#define for_each_bset(_b, _t) \ for (_t = (_b)->set; _t < (_b)->set + (_b)->nsets; _t++) +#define bset_tree_for_each_key(_b, _t, _k) \ + for (_k = btree_bkey_first(_b, _t); \ + _k != btree_bkey_last(_b, _t); \ + _k = bkey_next_skip_noops(_k, btree_bkey_last(_b, _t))) + static inline bool bset_has_ro_aux_tree(struct bset_tree *t) { return bset_aux_tree_type(t) == BSET_RO_AUX_TREE; -- cgit v1.2.3