Commit b71717da authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

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: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 9a796fdb
...@@ -253,12 +253,21 @@ void bch2_blacklist_entries_gc(struct work_struct *work) ...@@ -253,12 +253,21 @@ void bch2_blacklist_entries_gc(struct work_struct *work)
struct btree_iter iter; struct btree_iter iter;
struct btree *b; struct btree *b;
for_each_btree_node(&trans, iter, i, POS_MIN, bch2_trans_node_iter_init(&trans, &iter, i, POS_MIN,
BTREE_ITER_PREFETCH, b, ret) 0, 0, BTREE_ITER_PREFETCH);
if (test_bit(BCH_FS_STOPPING, &c->flags)) { retry:
bch2_trans_exit(&trans); bch2_trans_begin(&trans);
return;
} 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); bch2_trans_iter_exit(&trans, &iter);
} }
......
...@@ -136,6 +136,7 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags) ...@@ -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, bch2_trans_node_iter_init(&trans, &iter, id, POS_MIN, 0, 0,
BTREE_ITER_PREFETCH); BTREE_ITER_PREFETCH);
retry: retry:
ret = 0;
while (bch2_trans_begin(&trans), 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))) { !(ret = PTR_ERR_OR_ZERO(b))) {
......
...@@ -886,6 +886,7 @@ static int bch2_move_btree(struct bch_fs *c, ...@@ -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, bch2_trans_node_iter_init(&trans, &iter, id, POS_MIN, 0, 0,
BTREE_ITER_PREFETCH); BTREE_ITER_PREFETCH);
retry: retry:
ret = 0;
while (bch2_trans_begin(&trans), 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))) { !(ret = PTR_ERR_OR_ZERO(b))) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment