Commit 53b3e3c0 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix locking in bch2_btree_iter_traverse_cached()

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: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent c7bb769c
...@@ -298,7 +298,14 @@ int bch2_btree_iter_traverse_cached(struct btree_iter *iter) ...@@ -298,7 +298,14 @@ int bch2_btree_iter_traverse_cached(struct btree_iter *iter)
set_bit(BKEY_CACHED_ACCESSED, &ck->flags); set_bit(BKEY_CACHED_ACCESSED, &ck->flags);
iter->uptodate = BTREE_ITER_NEED_PEEK; iter->uptodate = BTREE_ITER_NEED_PEEK;
if (!(iter->flags & BTREE_ITER_INTENT))
bch2_btree_iter_downgrade(iter); bch2_btree_iter_downgrade(iter);
else if (!iter->locks_want) {
if (!__bch2_btree_iter_upgrade(iter, 1))
ret = -EINTR;
}
return ret; return ret;
err: err:
if (ret != -EINTR) { if (ret != -EINTR) {
......
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