diff options
Diffstat (limited to 'libbcachefs/ec.c')
-rw-r--r-- | libbcachefs/ec.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/libbcachefs/ec.c b/libbcachefs/ec.c index 740d3ef7..ad92d3b4 100644 --- a/libbcachefs/ec.c +++ b/libbcachefs/ec.c @@ -135,8 +135,6 @@ void bch2_stripe_to_text(struct printbuf *out, struct bch_fs *c, pr_buf(out, " %u:%llu:%u", s->ptrs[i].dev, (u64) s->ptrs[i].offset, stripe_blockcount_get(s, i)); - - bch2_bkey_ptrs_to_text(out, c, k); } static int ptr_matches_stripe(struct bch_fs *c, @@ -433,10 +431,9 @@ int bch2_ec_read_extent(struct bch_fs *c, struct bch_read_bio *rbio) closure_init_stack(&cl); - BUG_ON(!rbio->pick.idx || - rbio->pick.idx - 1 >= rbio->pick.ec_nr); + BUG_ON(!rbio->pick.has_ec); - stripe_idx = rbio->pick.ec[rbio->pick.idx - 1].idx; + stripe_idx = rbio->pick.ec.idx; buf = kzalloc(sizeof(*buf), GFP_NOIO); if (!buf) @@ -561,7 +558,7 @@ static int ec_stripe_mem_alloc(struct bch_fs *c, size_t idx = iter->pos.offset; int ret = 0; - if (!__ec_stripe_mem_alloc(c, idx, GFP_NOWAIT)) + if (!__ec_stripe_mem_alloc(c, idx, GFP_NOWAIT|__GFP_NOWARN)) return ret; bch2_trans_unlock(iter->trans); @@ -1278,7 +1275,7 @@ int bch2_stripes_read(struct bch_fs *c, struct journal_keys *journal_keys) struct btree_trans trans; struct btree_iter *btree_iter; struct journal_iter journal_iter; - struct bkey_s_c btree_k, journal_k, k; + struct bkey_s_c btree_k, journal_k; int ret; ret = bch2_fs_ec_start(c); @@ -1294,33 +1291,31 @@ int bch2_stripes_read(struct bch_fs *c, struct journal_keys *journal_keys) journal_k = bch2_journal_iter_peek(&journal_iter); while (1) { + bool btree; + if (btree_k.k && journal_k.k) { int cmp = bkey_cmp(btree_k.k->p, journal_k.k->p); - if (cmp < 0) { - k = btree_k; - btree_k = bch2_btree_iter_next(btree_iter); - } else if (cmp == 0) { + if (!cmp) btree_k = bch2_btree_iter_next(btree_iter); - k = journal_k; - journal_k = bch2_journal_iter_next(&journal_iter); - } else { - k = journal_k; - journal_k = bch2_journal_iter_next(&journal_iter); - } + btree = cmp < 0; } else if (btree_k.k) { - k = btree_k; - btree_k = bch2_btree_iter_next(btree_iter); + btree = true; } else if (journal_k.k) { - k = journal_k; - journal_k = bch2_journal_iter_next(&journal_iter); + btree = false; } else { break; } - bch2_mark_key(c, k, 0, 0, NULL, 0, + bch2_mark_key(c, btree ? btree_k : journal_k, + 0, 0, NULL, 0, BCH_BUCKET_MARK_ALLOC_READ| BCH_BUCKET_MARK_NOATOMIC); + + if (btree) + btree_k = bch2_btree_iter_next(btree_iter); + else + journal_k = bch2_journal_iter_next(&journal_iter); } ret = bch2_trans_exit(&trans) ?: ret; |