ob_push(c, ptrs, ob);
}
-enum bucket_alloc_ret
-bch2_bucket_alloc_set(struct bch_fs *c,
+int bch2_bucket_alloc_set(struct bch_fs *c,
struct open_buckets *ptrs,
struct dev_stripe_state *stripe,
struct bch_devs_mask *devs_may_alloc,
struct dev_alloc_list devs_sorted =
bch2_dev_alloc_list(c, stripe, devs_may_alloc);
struct bch_dev *ca;
- enum bucket_alloc_ret ret = INSUFFICIENT_DEVICES;
+ int ret = -INSUFFICIENT_DEVICES;
unsigned i;
BUG_ON(*nr_effective >= nr_replicas);
ob = bch2_bucket_alloc(c, ca, reserve,
flags & BUCKET_MAY_ALLOC_PARTIAL, cl);
if (IS_ERR(ob)) {
- ret = -PTR_ERR(ob);
+ ret = PTR_ERR(ob);
if (cl)
return ret;
bch2_dev_stripe_increment(ca, stripe);
if (*nr_effective >= nr_replicas)
- return ALLOC_SUCCESS;
+ return 0;
}
return ret;
* it's to a device we don't want:
*/
-static enum bucket_alloc_ret
-bucket_alloc_from_stripe(struct bch_fs *c,
+static int bucket_alloc_from_stripe(struct bch_fs *c,
struct open_buckets *ptrs,
struct write_point *wp,
struct bch_devs_mask *devs_may_alloc,
wp->ptrs = ptrs_skip;
}
-static enum bucket_alloc_ret
-open_bucket_add_buckets(struct bch_fs *c,
+static int open_bucket_add_buckets(struct bch_fs *c,
struct open_buckets *ptrs,
struct write_point *wp,
struct bch_devs_list *devs_have,
struct bch_devs_mask devs;
struct open_bucket *ob;
struct closure *cl = NULL;
- enum bucket_alloc_ret ret;
+ int ret;
unsigned i;
rcu_read_lock();
target, erasure_code,
nr_replicas, nr_effective,
have_cache, flags, _cl);
- if (ret == FREELIST_EMPTY ||
- ret == OPEN_BUCKETS_EMPTY)
+ if (ret == -FREELIST_EMPTY ||
+ ret == -OPEN_BUCKETS_EMPTY)
return ret;
if (*nr_effective >= nr_replicas)
return 0;
ret = bch2_bucket_alloc_set(c, ptrs, &wp->stripe, &devs,
nr_replicas, nr_effective, have_cache,
reserve, flags, cl);
- if (ret && ret != INSUFFICIENT_DEVICES && !cl && _cl) {
+ if (ret && ret != -INSUFFICIENT_DEVICES && !cl && _cl) {
cl = _cl;
goto retry_blocking;
}
unsigned nr_effective, write_points_nr;
unsigned ob_flags = 0;
bool have_cache;
- enum bucket_alloc_ret ret;
+ int ret;
int i;
if (!(flags & BCH_WRITE_ONLY_SPECIFIED_DEVS))
if (erasure_code && !ec_open_bucket(c, &ptrs))
pr_debug("failed to get ec bucket: ret %u", ret);
- if (ret == INSUFFICIENT_DEVICES &&
+ if (ret == -INSUFFICIENT_DEVICES &&
nr_effective >= nr_replicas_required)
ret = 0;
mutex_unlock(&wp->lock);
- if (ret == FREELIST_EMPTY &&
+ if (ret == -FREELIST_EMPTY &&
try_decrease_writepoints(c, write_points_nr))
goto retry;
switch (ret) {
- case OPEN_BUCKETS_EMPTY:
- case FREELIST_EMPTY:
+ case -OPEN_BUCKETS_EMPTY:
+ case -FREELIST_EMPTY:
return cl ? ERR_PTR(-EAGAIN) : ERR_PTR(-ENOSPC);
- case INSUFFICIENT_DEVICES:
+ case -INSUFFICIENT_DEVICES:
return ERR_PTR(-EROFS);
default:
BUG();
return h;
}
-static enum bucket_alloc_ret
-new_stripe_alloc_buckets(struct bch_fs *c, struct ec_stripe_head *h,
- struct closure *cl)
+static int new_stripe_alloc_buckets(struct bch_fs *c, struct ec_stripe_head *h,
+ struct closure *cl)
{
struct bch_devs_mask devs = h->devs;
struct open_bucket *ob;
struct open_buckets buckets;
unsigned i, j, nr_have_parity = 0, nr_have_data = 0;
bool have_cache = true;
- enum bucket_alloc_ret ret = ALLOC_SUCCESS;
+ int ret = 0;
for (i = 0; i < h->s->new_stripe.key.v.nr_blocks; i++) {
if (test_bit(i, h->s->blocks_gotten)) {
err:
bch2_ec_stripe_head_put(c, h);
- return ERR_PTR(-ret);
+ return ERR_PTR(ret);
}
void bch2_ec_stop_dev(struct bch_fs *c, struct bch_dev *ca)