summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_key_cache.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-08-22 23:39:23 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:40 -0400
commitd5024b011cb37b03aeeddd4b38857db427a04f11 (patch)
tree2c3af9da12a9e206aedf01cab24dfdbd92b67a3b /fs/bcachefs/btree_key_cache.c
parentca7d8fcabf29fae627babb72bda9b51763f9a145 (diff)
downloadlwn-d5024b011cb37b03aeeddd4b38857db427a04f11.tar.gz
lwn-d5024b011cb37b03aeeddd4b38857db427a04f11.zip
bcachefs: bch2_btree_node_lock_write_nofail()
Taking a write lock will be able to fail, with the new cycle detector - unless we pass it nofail, which is possible but not preferred. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_key_cache.c')
-rw-r--r--fs/bcachefs/btree_key_cache.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c
index 38a66302d6e9..94979b1a4912 100644
--- a/fs/bcachefs/btree_key_cache.c
+++ b/fs/bcachefs/btree_key_cache.c
@@ -342,11 +342,12 @@ static int btree_key_cache_fill(struct btree_trans *trans,
}
}
- /*
- * XXX: not allowed to be holding read locks when we take a write lock,
- * currently
- */
- bch2_btree_node_lock_write(trans, ck_path, ck_path->l[0].b);
+ ret = bch2_btree_node_lock_write(trans, ck_path, ck_path->l[0].b);
+ if (ret) {
+ kfree(new_k);
+ goto err;
+ }
+
if (new_k) {
kfree(ck->k);
ck->u64s = new_u64s;