Commit e829b717 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Ensure btree_iter_traverse() obeys iter->should_be_locked

iter->should_be_locked means that if bch2_btree_iter_relock() fails, we
need to restart the transaction.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent b4e09b35
......@@ -1403,6 +1403,15 @@ static int btree_iter_traverse_one(struct btree_iter *iter,
unsigned l, depth_want = iter->level;
int ret = 0;
/*
* Ensure we obey iter->should_be_locked: if it's set, we can't unlock
* and re-traverse the iterator without a transaction restart:
*/
if (iter->should_be_locked) {
ret = bch2_btree_iter_relock(iter, trace_ip) ? 0 : -EINTR;
goto out;
}
if (btree_iter_type(iter) == BTREE_ITER_CACHED) {
ret = bch2_btree_iter_traverse_cached(iter);
goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment