Skip to content

Commit be9fecd

Browse files
author
Kent Overstreet
committed
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 <[email protected]>
1 parent aac4947 commit be9fecd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fs/bcachefs/btree_locking.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,13 @@ bool __bch2_btree_path_upgrade_norestart(struct btree_trans *trans,
628628
{
629629
path->locks_want = new_locks_want;
630630

631-
struct get_locks_fail f = {};
632-
bool ret = !btree_path_get_locks(trans, path, true, &f, 0);
631+
/*
632+
* If we need it locked, we can't touch it. Otherwise, we can return
633+
* success - bch2_path_get() will use this path, and it'll just be
634+
* retraversed:
635+
*/
636+
bool ret = !btree_path_get_locks(trans, path, true, NULL, 0) ||
637+
!path->should_be_locked;
633638

634639
bch2_btree_path_verify_locks(path);
635640
return ret;

0 commit comments

Comments
 (0)