bcachefs: Fix erasure coding shutdown path
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 22 Feb 2023 23:35:51 +0000 (18:35 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:54 +0000 (17:09 -0400)
It's possible when shutting down to for a stripe head to have a new
stripe that doesn't yet have any blocks allocated - we just need to free
it.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/ec.c

index 4b054f7c4d4e106a944b2d65371555fe523a8970..123ca0b0b43f597a8019568158222f0c17bcf751 100644 (file)
@@ -1764,6 +1764,7 @@ void bch2_new_stripes_to_text(struct printbuf *out, struct bch_fs *c)
 void bch2_fs_ec_exit(struct bch_fs *c)
 {
        struct ec_stripe_head *h;
+       unsigned i;
 
        while (1) {
                mutex_lock(&c->ec_stripe_head_lock);
@@ -1775,7 +1776,12 @@ void bch2_fs_ec_exit(struct bch_fs *c)
                if (!h)
                        break;
 
-               BUG_ON(h->s);
+               if (h->s) {
+                       for (i = 0; i < h->s->new_stripe.key.v.nr_blocks; i++)
+                               BUG_ON(h->s->blocks[i]);
+
+                       kfree(h->s);
+               }
                kfree(h);
        }