summaryrefslogtreecommitdiff
path: root/libbcachefs/ec.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbcachefs/ec.c')
-rw-r--r--libbcachefs/ec.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/libbcachefs/ec.c b/libbcachefs/ec.c
index c409a426..8f39c4de 100644
--- a/libbcachefs/ec.c
+++ b/libbcachefs/ec.c
@@ -300,7 +300,7 @@ static unsigned ec_nr_failed(struct ec_stripe_buf *buf)
static int ec_do_recov(struct bch_fs *c, struct ec_stripe_buf *buf)
{
struct bch_stripe *v = &buf->key.v;
- unsigned i, failed[EC_STRIPE_MAX], nr_failed = 0;
+ unsigned i, failed[BCH_BKEY_PTRS_MAX], nr_failed = 0;
unsigned nr_data = v->nr_blocks - v->nr_redundant;
unsigned bytes = buf->size << 9;
@@ -874,7 +874,7 @@ static void ec_stripe_create(struct ec_stripe_new *s)
for_each_keylist_key(&s->keys, k) {
ret = ec_stripe_update_ptrs(c, &s->stripe, &k->k);
if (ret) {
- bch_err(c, "error creating stripe: error updating pointers");
+ bch_err(c, "error creating stripe: error %i updating pointers", ret);
break;
}
}
@@ -1101,7 +1101,7 @@ static int ec_new_stripe_alloc(struct bch_fs *c, struct ec_stripe_head *h)
s->c = c;
s->h = h;
s->nr_data = min_t(unsigned, h->nr_active_devs,
- EC_STRIPE_MAX) - h->redundancy;
+ BCH_BKEY_PTRS_MAX) - h->redundancy;
s->nr_parity = h->redundancy;
bch2_keylist_init(&s->keys, s->inline_keys);
@@ -1211,13 +1211,13 @@ static int new_stripe_alloc_buckets(struct bch_fs *c, struct ec_stripe_head *h)
struct open_bucket *ob;
unsigned i, nr_have, nr_data =
min_t(unsigned, h->nr_active_devs,
- EC_STRIPE_MAX) - h->redundancy;
+ BCH_BKEY_PTRS_MAX) - h->redundancy;
bool have_cache = true;
int ret = 0;
devs = h->devs;
- for_each_set_bit(i, h->s->blocks_allocated, EC_STRIPE_MAX) {
+ for_each_set_bit(i, h->s->blocks_allocated, BCH_BKEY_PTRS_MAX) {
__clear_bit(h->s->stripe.key.v.ptrs[i].dev, devs.d);
--nr_data;
}
@@ -1341,16 +1341,14 @@ struct ec_stripe_head *bch2_ec_stripe_head_get(struct bch_fs *c,
if (!h)
return NULL;
- if (!h->s && ec_new_stripe_alloc(c, h)) {
- bch2_ec_stripe_head_put(c, h);
- return NULL;
- }
-
- if (!h->s->allocated) {
- if (!h->s->existing_stripe &&
- (idx = get_existing_stripe(c, target, algo, redundancy)) >= 0) {
- //pr_info("got existing stripe %llu", idx);
+ if (!h->s) {
+ if (ec_new_stripe_alloc(c, h)) {
+ bch2_ec_stripe_head_put(c, h);
+ return NULL;
+ }
+ idx = get_existing_stripe(c, target, algo, redundancy);
+ if (idx >= 0) {
h->s->existing_stripe = true;
h->s->existing_stripe_idx = idx;
if (get_stripe_key(c, idx, &h->s->stripe)) {
@@ -1364,7 +1362,9 @@ struct ec_stripe_head *bch2_ec_stripe_head_get(struct bch_fs *c,
ec_block_io(c, &h->s->stripe, READ, i, &cl);
}
}
+ }
+ if (!h->s->allocated) {
if (!h->s->existing_stripe &&
!h->s->res.sectors) {
ret = bch2_disk_reservation_get(c, &h->s->res,