bcachefs: Fix bch2_dev_remove_alloc()

It was missing a lockrestart_do(), to call bch2_trans_begin() and also
handle transaction restarts.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
Kent Overstreet 2021-10-07 14:53:21 -04:00 committed by Kent Overstreet
parent 97996ddfdb
commit a9cb0a6706

View File

@ -1458,15 +1458,18 @@ static int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca)
bch2_trans_init(&trans, c, 0, 0);
for (i = 0; i < ca->mi.nbuckets; i++) {
ret = bch2_btree_key_cache_flush(&trans,
BTREE_ID_alloc, POS(ca->dev_idx, i));
ret = lockrestart_do(&trans,
bch2_btree_key_cache_flush(&trans,
BTREE_ID_alloc, POS(ca->dev_idx, i)));
if (ret)
break;
}
bch2_trans_exit(&trans);
if (ret)
if (ret) {
bch_err(c, "error %i removing dev alloc info", ret);
return ret;
}
return bch2_btree_delete_range(c, BTREE_ID_alloc,
POS(ca->dev_idx, 0),