summaryrefslogtreecommitdiff
path: root/fs/bcachefs/bset.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-11-16 05:52:12 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:46 +0300
commit4fcdd6ec345e1aeed23fbdbe53d62965c1a79b99 (patch)
treecfe98f33f2222015fb944dfa01c944c6b5e89234 /fs/bcachefs/bset.h
parent0f35e0860a73a35e8c3aa1afebc45e75eb2fbae6 (diff)
downloadlinux-4fcdd6ec345e1aeed23fbdbe53d62965c1a79b99.tar.xz
bcachefs: Btree split improvement
This improves the bkey_format calculation when splitting btree nodes. Previously, we'd use a format calculated for the original node for the lower of the two new nodes. This was particularly bad on sequential insertions, where we iteratively split the last btree node, whos format has to include KEY_MAX. Now, we calculate formats precisely for the keys the two new nodes will contain. This also should make splitting a bit more efficient, since we're only copying keys once (from the original node to the new node, instead of new node, replacement node, then upper split). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/bset.h')
-rw-r--r--fs/bcachefs/bset.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/bcachefs/bset.h b/fs/bcachefs/bset.h
index b352d5a40de0..fd2915a15070 100644
--- a/fs/bcachefs/bset.h
+++ b/fs/bcachefs/bset.h
@@ -447,6 +447,11 @@ struct bkey_s_c bch2_btree_node_iter_peek_unpack(struct btree_node_iter *,
struct btree *,
struct bkey *);
+#define for_each_btree_node_key(b, k, iter) \
+ for (bch2_btree_node_iter_init_from_start((iter), (b)); \
+ (k = bch2_btree_node_iter_peek((iter), (b))); \
+ bch2_btree_node_iter_advance(iter, b))
+
#define for_each_btree_node_key_unpack(b, k, iter, unpacked) \
for (bch2_btree_node_iter_init_from_start((iter), (b)); \
(k = bch2_btree_node_iter_peek_unpack((iter), (b), (unpacked))).k;\