summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_iter.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-07-15 20:51:09 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2022-07-16 23:50:30 -0400
commit94c820fc8efb341edcf91679180f129ce3dd9f40 (patch)
tree8bb12bfbaf4abc8bffd74fe7bd6bd4c6a447857e /fs/bcachefs/btree_iter.c
parent0f08cbeaab4da14aa9bdd6f520e753872156f3c2 (diff)
bcachefs: for_each_btree_key2()bcachefs-fsck-work
This introduces two new macros for iterating through the btree, with transaction restart handling - for_each_btree_key2() - for_each_btree_key_commit() Every iteration is now in an implicit transaction, and - as with lockrestart_do() and commit_do() - returning -EINTR will cause the transaction to be restarted, at the same key. This patch converts a bunch of code that was open coding this to these new macros, saving a substantial amount of code. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/btree_iter.c')
-rw-r--r--fs/bcachefs/btree_iter.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c
index 05bd0d60b5fb..e6de000a7def 100644
--- a/fs/bcachefs/btree_iter.c
+++ b/fs/bcachefs/btree_iter.c
@@ -1663,6 +1663,9 @@ out:
int __must_check bch2_btree_path_traverse(struct btree_trans *trans,
struct btree_path *path, unsigned flags)
{
+ if (!(local_clock() % 128))
+ return btree_trans_restart(trans);
+
if (path->uptodate < BTREE_ITER_NEED_RELOCK)
return 0;