bcachefs: Fix incorrectly freeing btree_path in alloc path
authorKent Overstreet <kent.overstreet@gmail.com>
Fri, 5 Aug 2022 21:08:35 +0000 (17:08 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:37 +0000 (17:09 -0400)
Clearing path->preserve means the path will be dropping in
bch2_trans_begin() - but on transaction restart, we're likely to need
that path again.

This fixes a livelock in the allocation path.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/btree_iter.h

index 9a3287da9a120ab96823ee4d933248f10d6943ac..5ca92b6bb3977593123ef0a446098b156de65ff2 100644 (file)
@@ -335,7 +335,8 @@ void bch2_trans_copy_iter(struct btree_iter *, struct btree_iter *);
 
 static inline void set_btree_iter_dontneed(struct btree_iter *iter)
 {
-       iter->path->preserve = false;
+       if (!iter->trans->restarted)
+               iter->path->preserve = false;
 }
 
 void *bch2_trans_kmalloc(struct btree_trans *, size_t);