bcachefs: for_each_btree_node() now returns errors directly
This changes for_each_btree_node() to work like for_each_btree_key(),
and to that end bch2_btree_iter_peek_node() and next_node() also return
error ptrs.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c
index 0db0ce5..2f60863 100644
--- a/fs/bcachefs/move.c
+++ b/fs/bcachefs/move.c
@@ -885,9 +885,10 @@ static int bch2_move_btree(struct bch_fs *c,
bch2_trans_node_iter_init(&trans, &iter, id, POS_MIN, 0, 0,
BTREE_ITER_PREFETCH);
-
+retry:
while (bch2_trans_begin(&trans),
- (b = bch2_btree_iter_peek_node(&iter))) {
+ (b = bch2_btree_iter_peek_node(&iter)) &&
+ !(ret = PTR_ERR_OR_ZERO(b))) {
if (kthread && kthread_should_stop())
break;
@@ -915,6 +916,9 @@ static int bch2_move_btree(struct bch_fs *c,
bch2_trans_cond_resched(&trans);
bch2_btree_iter_next_node(&iter);
}
+ if (ret == -EINTR)
+ goto retry;
+
bch2_trans_iter_exit(&trans, &iter);
if (kthread && kthread_should_stop())