summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/extents.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-05-14 21:28:37 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:03 -0400
commite1036ce5810222620c98660d64ccc649652cf6c9 (patch)
treef9eff0515ee3f1bf2e90539c781899b0bf0b9071 /fs/bcachefs/extents.h
parentfaf1a5f41772984d492f9805ded9a34dcdce724d (diff)
downloadlinux-e1036ce5810222620c98660d64ccc649652cf6c9.tar.gz
linux-e1036ce5810222620c98660d64ccc649652cf6c9.tar.bz2
linux-e1036ce5810222620c98660d64ccc649652cf6c9.zip
bcachefs: Repair code for multiple types of data in same bucket
bch2_check_fix_ptrs() is awkward, we need to find a way to improve it. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/extents.h')
-rw-r--r--fs/bcachefs/extents.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/bcachefs/extents.h b/fs/bcachefs/extents.h
index ccee43a2019d..9999805f955e 100644
--- a/fs/bcachefs/extents.h
+++ b/fs/bcachefs/extents.h
@@ -529,6 +529,30 @@ static inline struct bch_devs_list bch2_bkey_cached_devs(struct bkey_s_c k)
return ret;
}
+static inline unsigned bch2_bkey_ptr_data_type(struct bkey_s_c k, const struct bch_extent_ptr *ptr)
+{
+ switch (k.k->type) {
+ case KEY_TYPE_btree_ptr:
+ case KEY_TYPE_btree_ptr_v2:
+ return BCH_DATA_btree;
+ case KEY_TYPE_extent:
+ case KEY_TYPE_reflink_v:
+ return BCH_DATA_user;
+ case KEY_TYPE_stripe: {
+ struct bkey_s_c_stripe s = bkey_s_c_to_stripe(k);
+
+ BUG_ON(ptr < s.v->ptrs ||
+ ptr >= s.v->ptrs + s.v->nr_blocks);
+
+ return ptr >= s.v->ptrs + s.v->nr_blocks - s.v->nr_redundant
+ ? BCH_DATA_parity
+ : BCH_DATA_user;
+ }
+ default:
+ BUG();
+ }
+}
+
unsigned bch2_bkey_nr_ptrs(struct bkey_s_c);
unsigned bch2_bkey_nr_ptrs_allocated(struct bkey_s_c);
unsigned bch2_bkey_nr_ptrs_fully_allocated(struct bkey_s_c);