diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-03-02 05:47:07 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:55 +0300 |
commit | 910659763edaba58aa04bd5924dd933bc08cc56f (patch) | |
tree | 572a22a75d5a45db070052e7830b13088426e00d /fs/bcachefs/alloc_background.h | |
parent | 3329cf1bb91d6293a96cf35ad72b2a2e1e1c0e3d (diff) | |
download | linux-910659763edaba58aa04bd5924dd933bc08cc56f.tar.xz |
bcachefs: Mark stripe buckets with correct data type
Currently, we don't use bucket data type for tracking whether buckets
are part of a stripe; parity buckets are BCH_DATA_parity, but data
buckets in a stripe are BCH_DATA_user. There's a separate counter,
buckets_ec, outside the BCH_DATA_TYPES system for tracking number of
buckets on a device that are part of a stripe.
The trouble with this approach is that it's too coarse grained, and we
need better information on fragmentation for debugging copygc.
With this patch, data buckets in a stripe are now tracked as
BCH_DATA_stripe buckets.
This doesn't yet differentiate between erasure coded and non-erasure
coded data in a stripe bucket, nor do we yet track empty data buckets in
stripes.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/alloc_background.h')
-rw-r--r-- | fs/bcachefs/alloc_background.h | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h index 96ac8f396d46..c9ff590ef978 100644 --- a/fs/bcachefs/alloc_background.h +++ b/fs/bcachefs/alloc_background.h @@ -44,10 +44,10 @@ static inline enum bch_data_type __alloc_data_type(u32 dirty_sectors, struct bch_alloc_v4 a, enum bch_data_type data_type) { + if (stripe) + return data_type == BCH_DATA_parity ? data_type : BCH_DATA_stripe; if (dirty_sectors) return data_type; - if (stripe) - return BCH_DATA_stripe; if (cached_sectors) return BCH_DATA_cached; if (BCH_ALLOC_V4_NEED_DISCARD(&a)) @@ -64,19 +64,31 @@ static inline enum bch_data_type alloc_data_type(struct bch_alloc_v4 a, a.stripe, a, data_type); } +static inline enum bch_data_type bucket_data_type(enum bch_data_type data_type) +{ + return data_type == BCH_DATA_stripe ? BCH_DATA_user : data_type; +} + static inline u64 alloc_lru_idx_read(struct bch_alloc_v4 a) { return a.data_type == BCH_DATA_cached ? a.io_time[READ] : 0; } +#define DATA_TYPES_MOVABLE \ + ((1U << BCH_DATA_btree)| \ + (1U << BCH_DATA_user)| \ + (1U << BCH_DATA_stripe)) + +static inline bool data_type_movable(enum bch_data_type type) +{ + return (1U << type) & DATA_TYPES_MOVABLE; +} + static inline u64 alloc_lru_idx_fragmentation(struct bch_alloc_v4 a, struct bch_dev *ca) { - if (a.data_type != BCH_DATA_btree && - a.data_type != BCH_DATA_user) - return 0; - - if (a.dirty_sectors >= ca->mi.bucket_size) + if (!data_type_movable(a.data_type) || + a.dirty_sectors >= ca->mi.bucket_size) return 0; return div_u64((u64) a.dirty_sectors * (1ULL << 31), ca->mi.bucket_size); |