summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_iter.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-05-28 18:06:27 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:10:03 -0400
commitb5fd75669ab1283e7a9caf6288c425108bd382b0 (patch)
tree65003eef4cafbff47425bc4e726c2ab895c91e9d /fs/bcachefs/btree_iter.c
parent19c304bebda4d8815a20c8d3330459a112c329f6 (diff)
bcachefs: drop_locks_do()
Add a new helper for the common pattern of: - trans_unlock() - do something - trans_relock() Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_iter.c')
-rw-r--r--fs/bcachefs/btree_iter.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c
index 4830d203b37b..1cc53b37f78e 100644
--- a/fs/bcachefs/btree_iter.c
+++ b/fs/bcachefs/btree_iter.c
@@ -41,13 +41,10 @@ static struct btree_path *btree_path_alloc(struct btree_trans *, struct btree_pa
*/
static inline int bch2_trans_cond_resched(struct btree_trans *trans)
{
- if (need_resched() || race_fault()) {
- bch2_trans_unlock(trans);
- schedule();
- return bch2_trans_relock(trans);
- } else {
+ if (need_resched() || race_fault())
+ return drop_locks_do(trans, (schedule(), 0));
+ else
return 0;
- }
}
static inline int __btree_path_cmp(const struct btree_path *l,