summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-05-23 01:12:54 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2025-05-23 14:59:43 +0300
commitbe9fecdcdaf730dbf2ca70dbe5b6d42922df50d6 (patch)
tree6d55d830382367d0a61dc9a5cef1a9de126e564f
parentaac49471b6c4a15cdb4bdade8c19527075af073d (diff)
downloadlinux-be9fecdcdaf730dbf2ca70dbe5b6d42922df50d6.tar.xz
bcachefs: bch2_path_get() reuses paths if upgrade_fails & !should_be_locked
Small additional optimization over the previous patch, bringing us closer to the original behaviour, except when we need to clone to avoid a transaction restart. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/btree_locking.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c
index 6e43269a9c47..78f485ed1746 100644
--- a/fs/bcachefs/btree_locking.c
+++ b/fs/bcachefs/btree_locking.c
@@ -628,8 +628,13 @@ bool __bch2_btree_path_upgrade_norestart(struct btree_trans *trans,
{
path->locks_want = new_locks_want;
- struct get_locks_fail f = {};
- bool ret = !btree_path_get_locks(trans, path, true, &f, 0);
+ /*
+ * If we need it locked, we can't touch it. Otherwise, we can return
+ * success - bch2_path_get() will use this path, and it'll just be
+ * retraversed:
+ */
+ bool ret = !btree_path_get_locks(trans, path, true, NULL, 0) ||
+ !path->should_be_locked;
bch2_btree_path_verify_locks(path);
return ret;