summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/ec.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-04-22 17:21:35 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2024-05-08 17:29:20 -0400
commitc4e8db2b5d31fc488c644019b99bf41fd616895f (patch)
tree148c20b8a49e4382141c55ebf700486f1bc89049 /fs/bcachefs/ec.c
parentb769590f33dcb04cb8efc4905030f4a41df08e2b (diff)
downloadlinux-c4e8db2b5d31fc488c644019b99bf41fd616895f.tar.gz
linux-c4e8db2b5d31fc488c644019b99bf41fd616895f.tar.bz2
linux-c4e8db2b5d31fc488c644019b99bf41fd616895f.zip
bcachefs: bucket_data_type_mismatch()
We're working on potentially unifying bch2_check_bucket_ref() and bch2_check_fix_ptrs() - or at least eliminating gratuitious differences. Most immediately, there's a bunch of cleanups to be done regarding BCH_DATA_stripe. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/ec.c')
-rw-r--r--fs/bcachefs/ec.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 97ed598a55a5..4ccf71565961 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -165,15 +165,16 @@ void bch2_stripe_to_text(struct printbuf *out, struct bch_fs *c,
static int bch2_trans_mark_stripe_bucket(struct btree_trans *trans,
struct bkey_s_c_stripe s,
- unsigned idx, bool deleting)
+ unsigned ptr_idx, bool deleting)
{
struct bch_fs *c = trans->c;
- const struct bch_extent_ptr *ptr = &s.v->ptrs[idx];
+ const struct bch_extent_ptr *ptr = s.v->ptrs + ptr_idx;
struct btree_iter iter;
struct bkey_i_alloc_v4 *a;
- enum bch_data_type data_type = idx >= s.v->nr_blocks - s.v->nr_redundant
- ? BCH_DATA_parity : 0;
- s64 sectors = data_type ? le16_to_cpu(s.v->sectors) : 0;
+ unsigned nr_data = s.v->nr_blocks - s.v->nr_redundant;
+ bool parity = ptr_idx >= nr_data;
+ enum bch_data_type data_type = parity ? BCH_DATA_parity : BCH_DATA_stripe;
+ s64 sectors = parity ? le16_to_cpu(s.v->sectors) : 0;
int ret = 0;
if (deleting)
@@ -201,8 +202,8 @@ static int bch2_trans_mark_stripe_bucket(struct btree_trans *trans,
goto err;
}
- if (bch2_trans_inconsistent_on(data_type && a->v.dirty_sectors, trans,
- "bucket %llu:%llu gen %u data type %s dirty_sectors %u: data already in stripe bucket %llu",
+ if (bch2_trans_inconsistent_on(parity && a->v.dirty_sectors, trans,
+ "bucket %llu:%llu gen %u data type %s dirty_sectors %u: data already in parity bucket %llu",
iter.pos.inode, iter.pos.offset, a->v.gen,
bch2_data_type_str(a->v.data_type),
a->v.dirty_sectors,
@@ -213,7 +214,7 @@ static int bch2_trans_mark_stripe_bucket(struct btree_trans *trans,
a->v.stripe = s.k->p.offset;
a->v.stripe_redundancy = s.v->nr_redundant;
- a->v.data_type = BCH_DATA_stripe;
+ a->v.data_type = data_type;
} else {
if (bch2_trans_inconsistent_on(a->v.stripe != s.k->p.offset ||
a->v.stripe_redundancy != s.v->nr_redundant, trans,
@@ -230,8 +231,6 @@ static int bch2_trans_mark_stripe_bucket(struct btree_trans *trans,
}
a->v.dirty_sectors += sectors;
- if (data_type)
- a->v.data_type = !deleting ? data_type : 0;
ret = bch2_trans_update(trans, &iter, &a->k_i, 0);
if (ret)