bcachefs: Fix trans_lock_write()

On failure to get a write lock (because we had a conflicting read lock),
we need to make sure to upgrade the read lock to an intent lock - or we
could end up spinning.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
Kent Overstreet 2021-11-03 17:23:03 -04:00 committed by Kent Overstreet
parent f527afea5a
commit 85eb2bae7f

View File

@ -569,7 +569,8 @@ static inline bool have_conflicting_read_lock(struct btree_trans *trans, struct
//if (path == pos)
// break;
if (path->nodes_locked != path->nodes_intent_locked)
if (path->nodes_locked != path->nodes_intent_locked &&
!bch2_btree_path_upgrade(trans, path, path->level + 1))
return true;
}