summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/alloc_foreground.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs/alloc_foreground.c')
-rw-r--r--fs/bcachefs/alloc_foreground.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c
index 2d44ce2e11de..39e3bb5205ca 100644
--- a/fs/bcachefs/alloc_foreground.c
+++ b/fs/bcachefs/alloc_foreground.c
@@ -238,7 +238,7 @@ static struct open_bucket *__try_alloc_bucket(struct bch_fs *c, struct bch_dev *
c->blocked_allocate_open_bucket = local_clock();
spin_unlock(&c->freelist_lock);
- return ERR_PTR(-OPEN_BUCKETS_EMPTY);
+ return ERR_PTR(-BCH_ERR_open_buckets_empty);
}
/* Recheck under lock: */
@@ -440,7 +440,7 @@ again:
goto again;
}
- return ob ?: ERR_PTR(ret ?: -FREELIST_EMPTY);
+ return ob ?: ERR_PTR(ret ?: -BCH_ERR_no_buckets_found);
}
static struct open_bucket *bch2_bucket_alloc_freelist(struct btree_trans *trans,
@@ -548,7 +548,7 @@ again:
if (!c->blocked_allocate)
c->blocked_allocate = local_clock();
- ob = ERR_PTR(-FREELIST_EMPTY);
+ ob = ERR_PTR(-BCH_ERR_freelist_empty);
goto err;
}
@@ -579,7 +579,7 @@ again:
bch2_journal_flush_async(&c->journal, NULL);
err:
if (!ob)
- ob = ERR_PTR(-FREELIST_EMPTY);
+ ob = ERR_PTR(-BCH_ERR_no_buckets_found);
if (!IS_ERR(ob)) {
trace_bucket_alloc(ca, bch2_alloc_reserves[reserve],
@@ -591,7 +591,8 @@ err:
skipped_open,
skipped_need_journal_commit,
skipped_nouse,
- cl == NULL, PTR_ERR_OR_ZERO(ob));
+ cl == NULL,
+ "");
} else {
trace_bucket_alloc_fail(ca, bch2_alloc_reserves[reserve],
usage.d[BCH_DATA_free].buckets,
@@ -602,7 +603,8 @@ err:
skipped_open,
skipped_need_journal_commit,
skipped_nouse,
- cl == NULL, PTR_ERR_OR_ZERO(ob));
+ cl == NULL,
+ bch2_err_str(PTR_ERR(ob)));
atomic_long_inc(&c->bucket_alloc_fail);
}
@@ -750,7 +752,7 @@ static int bch2_bucket_alloc_set_trans(struct btree_trans *trans,
if (*nr_effective >= nr_replicas)
ret = 0;
else if (!ret)
- ret = -INSUFFICIENT_DEVICES;
+ ret = -BCH_ERR_insufficient_devices;
return ret;
}
@@ -923,8 +925,8 @@ static int open_bucket_add_buckets(struct btree_trans *trans,
nr_replicas, nr_effective,
have_cache, flags, _cl);
if (ret == -EINTR ||
- ret == -FREELIST_EMPTY ||
- ret == -OPEN_BUCKETS_EMPTY)
+ bch2_err_matches(ret, BCH_ERR_freelist_empty) ||
+ bch2_err_matches(ret, BCH_ERR_open_buckets_empty))
return ret;
if (*nr_effective >= nr_replicas)
return 0;
@@ -947,7 +949,7 @@ retry_blocking:
reserve, flags, cl);
if (ret &&
ret != -EINTR &&
- ret != -INSUFFICIENT_DEVICES &&
+ !bch2_err_matches(ret, BCH_ERR_insufficient_devices) &&
!cl && _cl) {
cl = _cl;
goto retry_blocking;
@@ -1203,7 +1205,7 @@ alloc_done:
if (erasure_code && !ec_open_bucket(c, &ptrs))
pr_debug("failed to get ec bucket: ret %u", ret);
- if (ret == -INSUFFICIENT_DEVICES &&
+ if (ret == -BCH_ERR_insufficient_devices &&
nr_effective >= nr_replicas_required)
ret = 0;
@@ -1234,19 +1236,18 @@ err:
mutex_unlock(&wp->lock);
- if (ret == -FREELIST_EMPTY &&
+ if (bch2_err_matches(ret, BCH_ERR_freelist_empty) &&
try_decrease_writepoints(c, write_points_nr))
goto retry;
- switch (ret) {
- case -OPEN_BUCKETS_EMPTY:
- case -FREELIST_EMPTY:
+ if (bch2_err_matches(ret, BCH_ERR_open_buckets_empty) ||
+ bch2_err_matches(ret, BCH_ERR_freelist_empty))
return cl ? -EAGAIN : -ENOSPC;
- case -INSUFFICIENT_DEVICES:
+
+ if (bch2_err_matches(ret, BCH_ERR_insufficient_devices))
return -EROFS;
- default:
- return ret;
- }
+
+ return ret;
}
int bch2_alloc_sectors_start(struct bch_fs *c,