From 180285b2df0e0c8e980b57ec411de3b74e6bfc20 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sat, 5 Mar 2022 15:21:07 -0500 Subject: bcachefs: Don't keep around btree_paths unnecessarily When bch2_trans_begin() is called and there hasn't been a transaction restart, we presume that we're now doing something new - iterating over different keys, and we now shouldn't keep aruond paths related to the previous transaction, excepting the subvolumes btree. This should fix some of our "transaction path overflow" bugs. Signed-off-by: Kent Overstreet --- fs/bcachefs/btree_iter.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 586aea50b9f8..29191451956f 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -3018,6 +3018,14 @@ void bch2_trans_begin(struct btree_trans *trans) trans_for_each_path(trans, path) { path->should_be_locked = false; + /* + * If the transaction wasn't restarted, we're presuming to be + * doing something new: dont keep iterators excpt the ones that + * are in use - except for the subvolumes btree: + */ + if (!trans->restarted && path->btree_id != BTREE_ID_subvolumes) + path->preserve = false; + /* * XXX: we probably shouldn't be doing this if the transaction * was restarted, but currently we still overflow transaction -- cgit v1.2.3