summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-12-11 12:02:48 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2020-12-16 15:29:51 -0500
commit402f8c41ed9660ee6d3eb5af8fc7f7c19af37abb (patch)
tree77f85740aaf5511505a68fc45fe5ffbba97c0230
parenta9b61b5faf25ec0b51bf6a44312c683d5695f12c (diff)
bcachefs: Fix btree node merge -> split operations
If a btree node merger is followed by a split or compact of the parent node, we could end up with the parent btree node iterator pointing to the whiteout inserted by the btree node merge operation - the fix is to ensure that interior btree node iterators always point to the first non whiteout. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--fs/bcachefs/btree_iter.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c
index 21253be5aab6..8c35e39ea97f 100644
--- a/fs/bcachefs/btree_iter.c
+++ b/fs/bcachefs/btree_iter.c
@@ -902,6 +902,13 @@ static inline void __btree_iter_init(struct btree_iter *iter,
bch2_btree_node_iter_init(&l->iter, l->b, &pos);
+ /*
+ * Iterators to interior nodes should always be pointed at the first non
+ * whiteout:
+ */
+ if (level)
+ bch2_btree_node_iter_peek(&l->iter, l->b);
+
btree_iter_set_dirty(iter, BTREE_ITER_NEED_PEEK);
}