summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteinar H. Gunderson <steinar+git@gunderson.no>2024-01-12 18:56:49 +0100
committerKent Overstreet <kent.overstreet@linux.dev>2024-01-12 13:09:51 -0500
commitb6afe1bed4fe47bc4e820ab17cbe8161a3b62c8e (patch)
tree906405a574cab627041e0d126089e7dc2a5e1204
parent2b7fda5aeeecc9f9575536d401395e4a9ecaaf26 (diff)
init_layout(): fix rounding
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>
-rw-r--r--libbcachefs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libbcachefs.c b/libbcachefs.c
index ceb60270..ef4cc718 100644
--- a/libbcachefs.c
+++ b/libbcachefs.c
@@ -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;