From: Kent Overstreet Date: Fri, 7 Feb 2025 21:58:34 +0000 (-0500) Subject: bcachefs: bch2_bkey_ptr_data_type() now correctly returns cached for cached ptrs X-Git-Tag: v6.15-rc1~146^2~128 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=34a493089af2f2f773c0c802e84b0a493115cd50;p=thirdparty%2Fkernel%2Flinux.git bcachefs: bch2_bkey_ptr_data_type() now correctly returns cached for cached ptrs Necessary for adding backpointers for cached pointers. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h index de25ba4ee94b5..c556ccaffe898 100644 --- a/fs/bcachefs/alloc_background.h +++ b/fs/bcachefs/alloc_background.h @@ -131,7 +131,7 @@ static inline enum bch_data_type alloc_data_type(struct bch_alloc_v4 a, if (a.stripe) return data_type == BCH_DATA_parity ? data_type : BCH_DATA_stripe; if (bch2_bucket_sectors_dirty(a)) - return data_type; + return bucket_data_type(data_type); if (a.cached_sectors) return BCH_DATA_cached; if (BCH_ALLOC_V4_NEED_DISCARD(&a)) diff --git a/fs/bcachefs/backpointers.h b/fs/bcachefs/backpointers.h index 5c6a17c21769c..7786731d4adaa 100644 --- a/fs/bcachefs/backpointers.h +++ b/fs/bcachefs/backpointers.h @@ -123,7 +123,12 @@ static inline enum bch_data_type bch2_bkey_ptr_data_type(struct bkey_s_c k, return BCH_DATA_btree; case KEY_TYPE_extent: case KEY_TYPE_reflink_v: - return p.has_ec ? BCH_DATA_stripe : BCH_DATA_user; + if (p.has_ec) + return BCH_DATA_stripe; + if (p.ptr.cached) + return BCH_DATA_cached; + else + return BCH_DATA_user; case KEY_TYPE_stripe: { const struct bch_extent_ptr *ptr = &entry->ptr; struct bkey_s_c_stripe s = bkey_s_c_to_stripe(k);