diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-01-15 00:19:23 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:08:51 +0300 |
commit | ac958006294ab462848bc69b9b5ddb1a8b99e748 (patch) | |
tree | 311ad2a818d2959fa9a3117d87f2b37c833acfa6 /fs/bcachefs/ec.c | |
parent | edfbba58e3e7a94900d24d266e6365b1ab531e3b (diff) | |
download | linux-ac958006294ab462848bc69b9b5ddb1a8b99e748.tar.xz |
bcachefs: Factor out bch2_ec_stripes_heap_start()
This fixes a bug where mark and sweep gc incorrectly was clearing out
the stripes heap and causing assertions to fire later - simpler to just
create the stripes heap after gc has finished.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/ec.c')
-rw-r--r-- | fs/bcachefs/ec.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index ce52344c79a6..1f125ce77e4f 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -1450,6 +1450,16 @@ unlock: mutex_unlock(&c->ec_stripe_head_lock); } +void bch2_stripes_heap_start(struct bch_fs *c) +{ + struct genradix_iter iter; + struct stripe *m; + + genradix_for_each(&c->stripes[0], iter, m) + if (m->alive) + bch2_stripes_heap_insert(c, m, iter.pos); +} + static int __bch2_stripe_write_key(struct btree_trans *trans, struct btree_iter *iter, struct stripe *m, @@ -1529,18 +1539,11 @@ static int bch2_stripes_read_fn(struct bch_fs *c, enum btree_id id, int ret = 0; if (k.k->type == KEY_TYPE_stripe) { - struct stripe *m; - ret = __ec_stripe_mem_alloc(c, k.k->p.offset, GFP_KERNEL) ?: bch2_mark_key(c, k, 0, 0, NULL, 0, BTREE_TRIGGER_NOATOMIC); if (ret) return ret; - - spin_lock(&c->ec_stripes_heap_lock); - m = genradix_ptr(&c->stripes[0], k.k->p.offset); - bch2_stripes_heap_insert(c, m, k.k->p.offset); - spin_unlock(&c->ec_stripes_heap_lock); } return ret; |