summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-11-03 17:23:03 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2021-12-25 17:37:08 -0500
commit1986000a8c5f516fc20ea4d8bf5d74fd35e0136f (patch)
treeff55044abe74eea1b1739ee8ce4baaaebab6f7aa
parent0c00ef0878d4189bc9416374caae58c8ff795ec9 (diff)
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>
-rw-r--r--fs/bcachefs/btree_update_leaf.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c
index 5cddb572a55a..b9c777cca23e 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;
}