bch2_btree_iter_traverse() is supposed to ensure we have the correct
type of lock - it was downgrading if necessary, but if we entered with a
read lock it wasn't upgrading to an intent lock, oops.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
set_bit(BKEY_CACHED_ACCESSED, &ck->flags);
iter->uptodate = BTREE_ITER_NEED_PEEK;
- bch2_btree_iter_downgrade(iter);
+
+ if (!(iter->flags & BTREE_ITER_INTENT))
+ bch2_btree_iter_downgrade(iter);
+ else if (!iter->locks_want) {
+ if (!__bch2_btree_iter_upgrade(iter, 1))
+ ret = -EINTR;
+ }
+
return ret;
err:
if (ret != -EINTR) {