From 85eb2bae7fd18f424b28c3f873d106c95e6b9733 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 3 Nov 2021 17:23:03 -0400 Subject: [PATCH] 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 --- fs/bcachefs/btree_update_leaf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 43ae2d83cfa7f..fa6ba018378b1 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -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; } -- 2.30.2