summaryrefslogtreecommitdiff
path: root/libbcachefs/alloc_background.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-06-17 11:31:26 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2024-06-17 12:38:43 -0400
commitfc06a0ea5e552663e9e47de941fbc7e621d4ca46 (patch)
tree7760020d71afe32d3317049ad6f1b493dabe245c /libbcachefs/alloc_background.h
parentab83e348fb77f91b3a9c09ab87c9c357bdafb1d7 (diff)
Update bcachefs sources to c56e1ec97dfd bcachefs: Fix bch2_sb_downgrade_update()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'libbcachefs/alloc_background.h')
-rw-r--r--libbcachefs/alloc_background.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/libbcachefs/alloc_background.h b/libbcachefs/alloc_background.h
index 59c08c79..dcf58c38 100644
--- a/libbcachefs/alloc_background.h
+++ b/libbcachefs/alloc_background.h
@@ -162,7 +162,13 @@ static inline u64 alloc_lru_idx_fragmentation(struct bch_alloc_v4 a,
!bch2_bucket_sectors_fragmented(ca, a))
return 0;
- u64 d = bch2_bucket_sectors_dirty(a);
+ /*
+ * avoid overflowing LRU_TIME_BITS on a corrupted fs, when
+ * bucket_sectors_dirty is (much) bigger than bucket_size
+ */
+ u64 d = min(bch2_bucket_sectors_dirty(a),
+ ca->mi.bucket_size);
+
return div_u64(d * (1ULL << 31), ca->mi.bucket_size);
}