diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index b65cd3566872..109efa73cd4c 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -3012,6 +3012,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