bcachefs: Handle transaction restarts in bch2_blacklist_entries_gc()

It shouldn't be necessary when we're only using a single iterator and
not doing updates, but that's harder to debug at the moment.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
Kent Overstreet 2021-10-19 15:11:45 -04:00 committed by Kent Overstreet
parent 9a796fdb06
commit b71717dac6
3 changed files with 17 additions and 6 deletions

View File

@ -253,12 +253,21 @@ void bch2_blacklist_entries_gc(struct work_struct *work)
struct btree_iter iter;
struct btree *b;
for_each_btree_node(&trans, iter, i, POS_MIN,
BTREE_ITER_PREFETCH, b, ret)
if (test_bit(BCH_FS_STOPPING, &c->flags)) {
bch2_trans_exit(&trans);
return;
}
bch2_trans_node_iter_init(&trans, &iter, i, POS_MIN,
0, 0, BTREE_ITER_PREFETCH);
retry:
bch2_trans_begin(&trans);
b = bch2_btree_iter_peek_node(&iter);
while (!(ret = PTR_ERR_OR_ZERO(b)) &&
b &&
!test_bit(BCH_FS_STOPPING, &c->flags))
b = bch2_btree_iter_next_node(&iter);
if (ret == -EINTR)
goto retry;
bch2_trans_iter_exit(&trans, &iter);
}

View File

@ -136,6 +136,7 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags)
bch2_trans_node_iter_init(&trans, &iter, id, POS_MIN, 0, 0,
BTREE_ITER_PREFETCH);
retry:
ret = 0;
while (bch2_trans_begin(&trans),
(b = bch2_btree_iter_peek_node(&iter)) &&
!(ret = PTR_ERR_OR_ZERO(b))) {

View File

@ -886,6 +886,7 @@ 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:
ret = 0;
while (bch2_trans_begin(&trans),
(b = bch2_btree_iter_peek_node(&iter)) &&
!(ret = PTR_ERR_OR_ZERO(b))) {