bcachefs: Fix bch2_dev_remove_alloc()
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 7 Oct 2021 18:53:21 +0000 (14:53 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:13 +0000 (17:09 -0400)
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>
fs/bcachefs/super.c

index a861ec32dbdecc00702b2df350097b20214fbaf3..db38d6b0f2adeda7c00b2e821a52216cf1a015df 100644 (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),