diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-12-15 12:38:17 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:50 -0400 |
commit | 2c40a2403e2b25aca38ba728385657dfca560a62 (patch) | |
tree | 0d563547117adc34f4e0049b2d396cebdd0ddacd /fs/bcachefs/ec.c | |
parent | 81d8599e192e85fa7e01d8a6e8e4095177ff46a3 (diff) | |
download | lwn-2c40a2403e2b25aca38ba728385657dfca560a62.tar.gz lwn-2c40a2403e2b25aca38ba728385657dfca560a62.zip |
bcachefs: Change allocations for ec stripes to blocking
We don't want writes to not get erasure coded just because the allocator
temporarily wasn't keeping up.
However, it's not guaranteed that these allocations will ever succeed,
we can currently get stuck - especially if devices are different sizes -
we still have work to do in this area.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/ec.c')
-rw-r--r-- | fs/bcachefs/ec.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index 72ee53dc95d0..f1659474b615 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -1228,10 +1228,9 @@ found: return h; } -/* - * XXX: use a higher watermark for allocating open buckets here: - */ -static int new_stripe_alloc_buckets(struct bch_fs *c, struct ec_stripe_head *h) +static enum bucket_alloc_ret +new_stripe_alloc_buckets(struct bch_fs *c, struct ec_stripe_head *h, + struct closure *cl) { struct bch_devs_mask devs; struct open_bucket *ob; @@ -1239,7 +1238,7 @@ static int new_stripe_alloc_buckets(struct bch_fs *c, struct ec_stripe_head *h) min_t(unsigned, h->nr_active_devs, BCH_BKEY_PTRS_MAX) - h->redundancy; bool have_cache = true; - int ret = 0; + enum bucket_alloc_ret ret = ALLOC_SUCCESS; devs = h->devs; @@ -1270,7 +1269,7 @@ static int new_stripe_alloc_buckets(struct bch_fs *c, struct ec_stripe_head *h) &have_cache, RESERVE_NONE, 0, - NULL); + cl); if (ret) goto err; } @@ -1286,7 +1285,7 @@ static int new_stripe_alloc_buckets(struct bch_fs *c, struct ec_stripe_head *h) &have_cache, RESERVE_NONE, 0, - NULL); + cl); if (ret) goto err; } @@ -1352,7 +1351,8 @@ static int get_stripe_key(struct bch_fs *c, u64 idx, struct ec_stripe_buf *strip struct ec_stripe_head *bch2_ec_stripe_head_get(struct bch_fs *c, unsigned target, unsigned algo, - unsigned redundancy) + unsigned redundancy, + struct closure *cl) { struct ec_stripe_head *h; struct open_bucket *ob; @@ -1421,14 +1421,13 @@ struct ec_stripe_head *bch2_ec_stripe_head_get(struct bch_fs *c, bch2_ec_stripe_head_put(c, h); h = NULL; goto out; - } - } - if (new_stripe_alloc_buckets(c, h)) { + ret = new_stripe_alloc_buckets(c, h, cl); + if (ret) { bch2_ec_stripe_head_put(c, h); - h = NULL; + h = ERR_PTR(-ret); goto out; } |