summaryrefslogtreecommitdiff
path: root/fs/bcachefs/journal_reclaim.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-05-31 07:13:39 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:05 +0300
commitd7fc453bdb012d5bc021e693896989fd5973823f (patch)
treeb6fbed2c5acb3a1cfc2a3e78306d621e4ec49292 /fs/bcachefs/journal_reclaim.c
parent649d9a4dfc834230b55c4ae34b60067d1d54c4d1 (diff)
downloadlinux-d7fc453bdb012d5bc021e693896989fd5973823f.tar.xz
bcachefs: Journal space calculation fix
When devices have different bucket sizes, we may accumulate a journal write that doesn't fit on some of our devices - previously, we'd underflow when calculating space on that device and then everything would get weird. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/journal_reclaim.c')
-rw-r--r--fs/bcachefs/journal_reclaim.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/bcachefs/journal_reclaim.c b/fs/bcachefs/journal_reclaim.c
index 812620d3de31..54d8e2f32a37 100644
--- a/fs/bcachefs/journal_reclaim.c
+++ b/fs/bcachefs/journal_reclaim.c
@@ -93,6 +93,10 @@ journal_dev_space_available(struct journal *j, struct bch_dev *ca,
* until we write it out - thus, account for it here:
*/
while ((unwritten = get_unwritten_sectors(j, &idx))) {
+ /* entry won't fit on this device, skip: */
+ if (unwritten > ca->mi.bucket_size)
+ continue;
+
if (unwritten >= sectors) {
if (!buckets) {
sectors = 0;