aboutsummaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorGravatar Kent Overstreet <kent.overstreet@linux.dev> 2023-03-03 02:43:39 -0500
committerGravatar Kent Overstreet <kent.overstreet@linux.dev> 2023-10-22 17:09:55 -0400
commita1fb08f5df6a8b2995d9daf8c2997cd478b51c55 (patch)
tree6c36435be6d403d82d46c7eb180e25d29ba80c56 /fs
parentbcachefs: Mark stripe buckets with correct data type (diff)
downloadlinux-a1fb08f5df6a8b2995d9daf8c2997cd478b51c55.tar.gz
linux-a1fb08f5df6a8b2995d9daf8c2997cd478b51c55.tar.bz2
linux-a1fb08f5df6a8b2995d9daf8c2997cd478b51c55.zip
bcachefs: Plumb alloc_reserve through stripe create path
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r--fs/bcachefs/alloc_foreground.c7
-rw-r--r--fs/bcachefs/ec.c40
-rw-r--r--fs/bcachefs/ec.h5
3 files changed, 23 insertions, 29 deletions
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c
index 161585de70c8..5aab85f1a835 100644
--- a/fs/bcachefs/alloc_foreground.c
+++ b/fs/bcachefs/alloc_foreground.c
@@ -794,6 +794,7 @@ static int bucket_alloc_from_stripe(struct btree_trans *trans,
unsigned nr_replicas,
unsigned *nr_effective,
bool *have_cache,
+ enum alloc_reserve reserve,
unsigned flags,
struct closure *cl)
{
@@ -813,9 +814,7 @@ static int bucket_alloc_from_stripe(struct btree_trans *trans,
if (ec_open_bucket(c, ptrs))
return 0;
- h = bch2_ec_stripe_head_get(trans, target, 0, nr_replicas - 1,
- wp == &c->copygc_write_point,
- cl);
+ h = bch2_ec_stripe_head_get(trans, target, 0, nr_replicas - 1, reserve, cl);
if (IS_ERR(h))
return PTR_ERR(h);
if (!h)
@@ -926,7 +925,7 @@ static int open_bucket_add_buckets(struct btree_trans *trans,
ret = bucket_alloc_from_stripe(trans, ptrs, wp, &devs,
target, erasure_code,
nr_replicas, nr_effective,
- have_cache, flags, _cl);
+ have_cache, reserve, flags, _cl);
if (bch2_err_matches(ret, BCH_ERR_transaction_restart) ||
bch2_err_matches(ret, BCH_ERR_freelist_empty) ||
bch2_err_matches(ret, BCH_ERR_open_buckets_empty))
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 88c4873e1833..4bf655b0de0a 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -1336,7 +1336,7 @@ static int ec_new_stripe_alloc(struct bch_fs *c, struct ec_stripe_head *h)
static struct ec_stripe_head *
ec_new_stripe_head_alloc(struct bch_fs *c, unsigned target,
unsigned algo, unsigned redundancy,
- bool copygc)
+ enum alloc_reserve reserve)
{
struct ec_stripe_head *h;
struct bch_dev *ca;
@@ -1352,7 +1352,7 @@ ec_new_stripe_head_alloc(struct bch_fs *c, unsigned target,
h->target = target;
h->algo = algo;
h->redundancy = redundancy;
- h->copygc = copygc;
+ h->reserve = reserve;
rcu_read_lock();
h->devs = target_rw_devs(c, BCH_DATA_user, target);
@@ -1387,7 +1387,7 @@ struct ec_stripe_head *__bch2_ec_stripe_head_get(struct btree_trans *trans,
unsigned target,
unsigned algo,
unsigned redundancy,
- bool copygc)
+ enum alloc_reserve reserve)
{
struct bch_fs *c = trans->c;
struct ec_stripe_head *h;
@@ -1404,21 +1404,21 @@ struct ec_stripe_head *__bch2_ec_stripe_head_get(struct btree_trans *trans,
if (h->target == target &&
h->algo == algo &&
h->redundancy == redundancy &&
- h->copygc == copygc) {
+ h->reserve == reserve) {
ret = bch2_trans_mutex_lock(trans, &h->lock);
if (ret)
h = ERR_PTR(ret);
goto found;
}
- h = ec_new_stripe_head_alloc(c, target, algo, redundancy, copygc);
+ h = ec_new_stripe_head_alloc(c, target, algo, redundancy, reserve);
found:
mutex_unlock(&c->ec_stripe_head_lock);
return h;
}
static int new_stripe_alloc_buckets(struct btree_trans *trans, struct ec_stripe_head *h,
- struct closure *cl)
+ enum alloc_reserve reserve, struct closure *cl)
{
struct bch_fs *c = trans->c;
struct bch_devs_mask devs = h->devs;
@@ -1428,14 +1428,12 @@ static int new_stripe_alloc_buckets(struct btree_trans *trans, struct ec_stripe_
bool have_cache = true;
int ret = 0;
- for (i = 0; i < h->s->new_stripe.key.v.nr_blocks; i++) {
- if (test_bit(i, h->s->blocks_gotten)) {
- __clear_bit(h->s->new_stripe.key.v.ptrs[i].dev, devs.d);
- if (i < h->s->nr_data)
- nr_have_data++;
- else
- nr_have_parity++;
- }
+ for_each_set_bit(i, h->s->blocks_gotten, h->s->new_stripe.key.v.nr_blocks) {
+ __clear_bit(h->s->new_stripe.key.v.ptrs[i].dev, devs.d);
+ if (i < h->s->nr_data)
+ nr_have_data++;
+ else
+ nr_have_parity++;
}
BUG_ON(nr_have_data > h->s->nr_data);
@@ -1449,9 +1447,7 @@ static int new_stripe_alloc_buckets(struct btree_trans *trans, struct ec_stripe_
h->s->nr_parity,
&nr_have_parity,
&have_cache,
- h->copygc
- ? RESERVE_movinggc
- : RESERVE_none,
+ reserve,
0,
cl);
@@ -1478,9 +1474,7 @@ static int new_stripe_alloc_buckets(struct btree_trans *trans, struct ec_stripe_
h->s->nr_data,
&nr_have_data,
&have_cache,
- h->copygc
- ? RESERVE_movinggc
- : RESERVE_none,
+ reserve,
0,
cl);
@@ -1640,7 +1634,7 @@ struct ec_stripe_head *bch2_ec_stripe_head_get(struct btree_trans *trans,
unsigned target,
unsigned algo,
unsigned redundancy,
- bool copygc,
+ enum alloc_reserve reserve,
struct closure *cl)
{
struct bch_fs *c = trans->c;
@@ -1648,7 +1642,7 @@ struct ec_stripe_head *bch2_ec_stripe_head_get(struct btree_trans *trans,
int ret;
bool needs_stripe_new;
- h = __bch2_ec_stripe_head_get(trans, target, algo, redundancy, copygc);
+ h = __bch2_ec_stripe_head_get(trans, target, algo, redundancy, reserve);
if (!h)
bch_err(c, "no stripe head");
if (IS_ERR_OR_NULL(h))
@@ -1685,7 +1679,7 @@ struct ec_stripe_head *bch2_ec_stripe_head_get(struct btree_trans *trans,
}
if (!h->s->allocated) {
- ret = new_stripe_alloc_buckets(trans, h, cl);
+ ret = new_stripe_alloc_buckets(trans, h, reserve, cl);
if (ret)
goto err;
diff --git a/fs/bcachefs/ec.h b/fs/bcachefs/ec.h
index c9e4fb214649..56d1b5e7d797 100644
--- a/fs/bcachefs/ec.h
+++ b/fs/bcachefs/ec.h
@@ -181,7 +181,7 @@ struct ec_stripe_head {
unsigned target;
unsigned algo;
unsigned redundancy;
- bool copygc;
+ enum alloc_reserve reserve;
struct bch_devs_mask devs;
unsigned nr_active_devs;
@@ -205,7 +205,8 @@ int bch2_ec_stripe_new_alloc(struct bch_fs *, struct ec_stripe_head *);
void bch2_ec_stripe_head_put(struct bch_fs *, struct ec_stripe_head *);
struct ec_stripe_head *bch2_ec_stripe_head_get(struct btree_trans *,
- unsigned, unsigned, unsigned, bool, struct closure *);
+ unsigned, unsigned, unsigned,
+ enum alloc_reserve, struct closure *);
void bch2_stripes_heap_update(struct bch_fs *, struct stripe *, size_t);
void bch2_stripes_heap_del(struct bch_fs *, struct stripe *, size_t);