summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-03-21 21:06:43 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-04-06 19:13:44 -0400
commitb1404364924298f84213ca089ec167be953cf16d (patch)
treec0a3d3627fe864c1566adb979763f8bed1938398
parent3bc11e3bb07dab3f42f8233bb0b1abf1df8e88ad (diff)
bcachefs: alloc_request.data_type
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/alloc_foreground.c10
-rw-r--r--fs/bcachefs/alloc_foreground.h4
-rw-r--r--fs/bcachefs/ec.c12
3 files changed, 11 insertions, 15 deletions
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c
index 600a5bab5e57..58438999594d 100644
--- a/fs/bcachefs/alloc_foreground.c
+++ b/fs/bcachefs/alloc_foreground.c
@@ -716,7 +716,6 @@ static int add_new_bucket(struct bch_fs *c,
int bch2_bucket_alloc_set_trans(struct btree_trans *trans,
struct alloc_request *req,
struct dev_stripe_state *stripe,
- enum bch_data_type data_type,
struct closure *cl)
{
struct bch_fs *c = trans->c;
@@ -737,7 +736,7 @@ int bch2_bucket_alloc_set_trans(struct btree_trans *trans,
struct bch_dev_usage usage;
struct open_bucket *ob = bch2_bucket_alloc_trans(trans, ca,
- req->watermark, data_type,
+ req->watermark, req->data_type,
cl, req->flags & BCH_WRITE_alloc_nowait,
&usage);
if (!IS_ERR(ob))
@@ -933,8 +932,7 @@ retry_blocking:
* Try nonblocking first, so that if one device is full we'll try from
* other devices:
*/
- ret = bch2_bucket_alloc_set_trans(trans, req, &req->wp->stripe,
- req->wp->data_type, cl);
+ ret = bch2_bucket_alloc_set_trans(trans, req, &req->wp->stripe, cl);
if (ret &&
!bch2_err_matches(ret, BCH_ERR_transaction_restart) &&
!bch2_err_matches(ret, BCH_ERR_insufficient_devices) &&
@@ -1285,12 +1283,14 @@ retry:
*wp_ret = req.wp = writepoint_find(trans, write_point.v);
+ req.data_type = req.wp->data_type;
+
ret = bch2_trans_relock(trans);
if (ret)
goto err;
/* metadata may not allocate on cache devices: */
- if (req.wp->data_type != BCH_DATA_user)
+ if (req.data_type != BCH_DATA_user)
req.have_cache = true;
if (target && !(flags & BCH_WRITE_only_specified_devs)) {
diff --git a/fs/bcachefs/alloc_foreground.h b/fs/bcachefs/alloc_foreground.h
index 741d81611f92..15135b6b63ce 100644
--- a/fs/bcachefs/alloc_foreground.h
+++ b/fs/bcachefs/alloc_foreground.h
@@ -30,6 +30,7 @@ struct alloc_request {
bool ec;
enum bch_watermark watermark;
enum bch_write_flags flags;
+ enum bch_data_type data_type;
struct bch_devs_list *devs_have;
struct write_point *wp;
@@ -189,8 +190,7 @@ static inline bool bch2_bucket_is_open_safe(struct bch_fs *c, unsigned dev, u64
enum bch_write_flags;
int bch2_bucket_alloc_set_trans(struct btree_trans *, struct alloc_request *,
- struct dev_stripe_state *, enum bch_data_type,
- struct closure *);
+ struct dev_stripe_state *, struct closure *);
int bch2_alloc_sectors_start_trans(struct btree_trans *,
unsigned, unsigned,
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 7477147af26e..641a500fcd35 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -1761,11 +1761,9 @@ static int new_stripe_alloc_buckets(struct btree_trans *trans,
if (nr_have_parity < s->nr_parity) {
req.nr_replicas = s->nr_parity;
req.nr_effective = nr_have_parity;
+ req.data_type = BCH_DATA_parity;
- ret = bch2_bucket_alloc_set_trans(trans, &req,
- &h->parity_stripe,
- BCH_DATA_parity,
- cl);
+ ret = bch2_bucket_alloc_set_trans(trans, &req, &h->parity_stripe, cl);
open_bucket_for_each(c, &req.ptrs, ob, i) {
j = find_next_zero_bit(s->blocks_gotten,
@@ -1786,11 +1784,9 @@ static int new_stripe_alloc_buckets(struct btree_trans *trans,
if (nr_have_data < s->nr_data) {
req.nr_replicas = s->nr_data;
req.nr_effective = nr_have_data;
+ req.data_type = BCH_DATA_user;
- ret = bch2_bucket_alloc_set_trans(trans, &req,
- &h->block_stripe,
- BCH_DATA_user,
- cl);
+ ret = bch2_bucket_alloc_set_trans(trans, &req, &h->block_stripe, cl);
open_bucket_for_each(c, &req.ptrs, ob, i) {
j = find_next_zero_bit(s->blocks_gotten,