diff options
Diffstat (limited to 'libbcachefs/extents.c')
-rw-r--r-- | libbcachefs/extents.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/libbcachefs/extents.c b/libbcachefs/extents.c index 1b86d27e..dcd70994 100644 --- a/libbcachefs/extents.c +++ b/libbcachefs/extents.c @@ -67,7 +67,7 @@ unsigned bch2_bkey_nr_dirty_ptrs(struct bkey_s_c k) static unsigned bch2_extent_ptr_durability(struct bch_fs *c, struct extent_ptr_decoded p) { - unsigned i, durability = 0; + unsigned durability = 0; struct bch_dev *ca; if (p.ptr.cached) @@ -78,16 +78,16 @@ static unsigned bch2_extent_ptr_durability(struct bch_fs *c, if (ca->mi.state != BCH_MEMBER_STATE_FAILED) durability = max_t(unsigned, durability, ca->mi.durability); - for (i = 0; i < p.ec_nr; i++) { + if (p.has_ec) { struct stripe *s = - genradix_ptr(&c->stripes[0], p.idx); + genradix_ptr(&c->stripes[0], p.ec.idx); if (WARN_ON(!s)) - continue; + goto out; durability = max_t(unsigned, durability, s->nr_redundant); } - +out: return durability; } @@ -206,10 +206,10 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k, p.idx++; if (force_reconstruct_read(c) && - !p.idx && p.ec_nr) + !p.idx && p.has_ec) p.idx++; - if (p.idx >= p.ec_nr + 1) + if (p.idx >= (unsigned) p.has_ec + 1) continue; if (ret > 0 && !ptr_better(c, p, *pick)) @@ -1011,13 +1011,19 @@ int bch2_extent_atomic_end(struct btree_iter *iter, struct bpos *end) { struct btree_trans *trans = iter->trans; - struct btree *b = iter->l[0].b; - struct btree_node_iter node_iter = iter->l[0].iter; + struct btree *b; + struct btree_node_iter node_iter; struct bkey_packed *_k; unsigned nr_iters = 0; int ret; - BUG_ON(iter->uptodate > BTREE_ITER_NEED_PEEK); + ret = bch2_btree_iter_traverse(iter); + if (ret) + return ret; + + b = iter->l[0].b; + node_iter = iter->l[0].iter; + BUG_ON(bkey_cmp(bkey_start_pos(&insert->k), b->data->min_key) < 0); *end = bpos_min(insert->k.p, b->key.k.p); @@ -1538,7 +1544,6 @@ void bch2_extent_ptr_decoded_append(struct bkey_i *k, struct bch_extent_crc_unpacked crc = bch2_extent_crc_unpack(&k->k, NULL); union bch_extent_entry *pos; - unsigned i; if (!bch2_crc_unpacked_cmp(crc, p->crc)) { pos = ptrs.start; @@ -1557,9 +1562,9 @@ found: p->ptr.type = 1 << BCH_EXTENT_ENTRY_ptr; __extent_entry_insert(k, pos, to_entry(&p->ptr)); - for (i = 0; i < p->ec_nr; i++) { - p->ec[i].type = 1 << BCH_EXTENT_ENTRY_stripe_ptr; - __extent_entry_insert(k, pos, to_entry(&p->ec[i])); + if (p->has_ec) { + p->ec.type = 1 << BCH_EXTENT_ENTRY_stripe_ptr; + __extent_entry_insert(k, pos, to_entry(&p->ec)); } } |