]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Fix additional misalignment in journal space calculations
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 7 Jul 2025 17:54:31 +0000 (13:54 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 7 Jul 2025 22:19:30 +0000 (18:19 -0400)
Additional fix on top of

f54b2a80d0df bcachefs: Fix misaligned bucket check in journal space calculations

Make sure that when we calculate space for the next entry it's not
misaligned: we need to round_down() to filesystem block size in multiple
places (next entry size calculation as well as total space available).

Reported-by: Ondřej Kraus <neverberlerfellerer@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/journal_reclaim.c

index cd6201741c59e3932f119b8df2169dfd79ed411d..0042d43b8e57f805a2b1300ce672c09fc1593483 100644 (file)
@@ -169,6 +169,12 @@ static struct journal_space __journal_space_available(struct journal *j, unsigne
        if (nr_devs < nr_devs_want)
                return (struct journal_space) { 0, 0 };
 
+       /*
+        * It's possible for bucket size to be misaligned w.r.t. the filesystem
+        * block size:
+        */
+       min_bucket_size = round_down(min_bucket_size, block_sectors(c));
+
        /*
         * We sorted largest to smallest, and we want the smallest out of the
         * @nr_devs_want largest devices: