diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-11-04 15:56:04 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:31 -0400 |
commit | f58c22e76febdfeff9c92fe7f3355bd1eea6645b (patch) | |
tree | 94832526bee0db2e9b4ab77ccc28709392c8ef94 /fs | |
parent | e2ee3eaab72a059b29f079290b5773509df9524f (diff) |
bcachefs: Avoid calling bch2_btree_iter_relock() in bch2_btree_iter_traverse()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/btree_iter.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index f849120fcbce..f05a5e718181 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -294,9 +294,7 @@ void bch2_btree_trans_verify_locks(struct btree_trans *trans) __flatten static bool bch2_btree_iter_relock(struct btree_iter *iter, bool trace) { - return iter->uptodate >= BTREE_ITER_NEED_RELOCK - ? btree_iter_get_locks(iter, false, trace) - : true; + return btree_iter_get_locks(iter, false, trace); } bool __bch2_btree_iter_upgrade(struct btree_iter *iter, @@ -1098,7 +1096,15 @@ static int btree_iter_traverse_one(struct btree_iter *iter) if (unlikely(iter->level >= BTREE_MAX_DEPTH)) return 0; - if (bch2_btree_iter_relock(iter, false)) + /* + * if we need interior nodes locked, call btree_iter_relock() to make + * sure we walk back up enough that we lock them: + */ + if (iter->uptodate == BTREE_ITER_NEED_RELOCK || + iter->locks_want > 1) + bch2_btree_iter_relock(iter, false); + + if (iter->uptodate < BTREE_ITER_NEED_RELOCK) return 0; /* |