bcachefs: Don't try to delete stripes when RO
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 10 Jul 2019 20:04:58 +0000 (16:04 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:24 +0000 (17:08 -0400)
We weren't checking for errors when trying to delet stripes, which meant
ec_stripe_delete_work() would spin trying to delete the same stripe over
and over.

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

index 40acd1ec46452520f8588254a604142bb5c08130..6d59631b8259b8dc2cae74d875511f678e02be90 100644 (file)
@@ -626,7 +626,8 @@ void bch2_stripes_heap_update(struct bch_fs *c,
                bch2_stripes_heap_insert(c, m, idx);
        }
 
-       if (stripe_idx_to_delete(c) >= 0)
+       if (stripe_idx_to_delete(c) >= 0 &&
+           !percpu_ref_is_dying(&c->writes))
                schedule_work(&c->ec_stripe_delete_work);
 }
 
@@ -684,7 +685,8 @@ static void ec_stripe_delete_work(struct work_struct *work)
                if (idx < 0)
                        break;
 
-               ec_stripe_delete(c, idx);
+               if (ec_stripe_delete(c, idx))
+                       break;
        }
 
        mutex_unlock(&c->ec_stripe_create_lock);
index 4c54ac64b0afff771db91567d7939eee2ce53e09..91562b95bd9737ba5947d8f60e1218ede19bfb9b 100644 (file)
@@ -366,6 +366,8 @@ static int bch2_fs_read_write_late(struct bch_fs *c)
 
        schedule_delayed_work(&c->pd_controllers_update, 5 * HZ);
 
+       schedule_work(&c->ec_stripe_delete_work);
+
        return 0;
 }