summaryrefslogtreecommitdiff
path: root/libbcachefs/btree_update_interior.h
diff options
context:
space:
mode:
Diffstat (limited to 'libbcachefs/btree_update_interior.h')
-rw-r--r--libbcachefs/btree_update_interior.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/libbcachefs/btree_update_interior.h b/libbcachefs/btree_update_interior.h
index 25bfc7ab..abf14e4c 100644
--- a/libbcachefs/btree_update_interior.h
+++ b/libbcachefs/btree_update_interior.h
@@ -183,9 +183,14 @@ void bch2_btree_root_alloc(struct bch_fs *, enum btree_id);
static inline unsigned btree_update_reserve_required(struct bch_fs *c,
struct btree *b)
{
- unsigned depth = btree_node_root(c, b)->level - b->level;
+ unsigned depth = btree_node_root(c, b)->level - b->level + 1;
- return btree_reserve_required_nodes(depth);
+ /*
+ * Number of nodes we might have to allocate in a worst case btree
+ * split operation - we split all the way up to the root, then allocate
+ * a new root.
+ */
+ return depth * 2 + 1;
}
static inline void btree_node_reset_sib_u64s(struct btree *b)