]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
init_layout(): fix rounding
authorSteinar H. Gunderson <steinar+git@gunderson.no>
Fri, 12 Jan 2024 17:56:49 +0000 (18:56 +0100)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 12 Jan 2024 18:09:51 +0000 (13:09 -0500)
block_size is in bytes, not sectors, so when calling round_up(),
we could start rounding up by a way too large size and then overflow
outside the area that migrate allocated for us.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
libbcachefs.c

index ceb6027016c32d21595b265f9e34555fac6aedd6..ef4cc7181f877e30f1b976f45051160eeda875ac 100644 (file)
@@ -48,7 +48,7 @@ static void init_layout(struct bch_sb_layout *l,
        /* Create two superblocks in the allowed range: */
        for (i = 0; i < l->nr_superblocks; i++) {
                if (sb_pos != BCH_SB_SECTOR)
-                       sb_pos = round_up(sb_pos, block_size);
+                       sb_pos = round_up(sb_pos, block_size >> 9);
 
                l->sb_offset[i] = cpu_to_le64(sb_pos);
                sb_pos += sb_size;