diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index 6d59631b8259..42bca2b413e3 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -575,7 +575,8 @@ static ssize_t stripe_idx_to_delete(struct bch_fs *c) { ec_stripes_heap *h = &c->ec_stripes_heap; - return h->data[0].blocks_nonempty == 0 ? h->data[0].idx : -1; + return h->used && h->data[0].blocks_nonempty == 0 + ? h->data[0].idx : -1; } static inline int ec_stripes_heap_cmp(ec_stripes_heap *h, diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index 91562b95bd97..202c0b443ef4 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -277,6 +277,7 @@ void bch2_fs_read_only(struct bch_fs *c) */ percpu_ref_kill(&c->writes); + cancel_work_sync(&c->ec_stripe_delete_work); cancel_delayed_work(&c->pd_controllers_update); /*