bcachefs: Ensure journal space is block size aligned
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 18 Apr 2025 20:42:50 +0000 (16:42 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 20 Apr 2025 23:41:38 +0000 (19:41 -0400)
We don't require that bucket size is block size aligned (although it
should be!) - so we need to handle this in the journal code.

This fixes an assertion pop in jorunal_entry_close(), where the journal
entry overruns available space - after rounding it up to block size.

Fixes: https://github.com/koverstreet/bcachefs/issues/854
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/journal_reclaim.c

index 5d1547aa118ac841dc49ffa02f756ec2bc6ff454..ea670c3c43d8a08a2f2b12e00b7bd584b5fbccac 100644 (file)
@@ -252,7 +252,10 @@ void bch2_journal_space_available(struct journal *j)
 
        bch2_journal_set_watermark(j);
 out:
-       j->cur_entry_sectors    = !ret ? j->space[journal_space_discarded].next_entry : 0;
+       j->cur_entry_sectors    = !ret
+               ? round_down(j->space[journal_space_discarded].next_entry,
+                            block_sectors(c))
+               : 0;
        j->cur_entry_error      = ret;
 
        if (!ret)