summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-12-19 21:55:09 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2021-12-19 21:55:09 -0500
commit6a4f458a4835b37b044927dc7ef44e3b3b5faddd (patch)
tree5320189bb7b164aeb37c621e408faaa0989457e6
parentd06f5690fab526c4a4a8a4d55f9c4e675d883be9 (diff)
fix init_layout()
It was incorrectly failing when we did have enough space for the superblocks - >= should have been >. Also, give it a better error message. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--libbcachefs.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/libbcachefs.c b/libbcachefs.c
index 85523c62..74a38f83 100644
--- a/libbcachefs.c
+++ b/libbcachefs.c
@@ -40,6 +40,7 @@ static void init_layout(struct bch_sb_layout *l,
unsigned sb_size,
u64 sb_start, u64 sb_end)
{
+ u64 sb_pos = sb_start;
unsigned i;
memset(l, 0, sizeof(*l));
@@ -51,15 +52,16 @@ 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_start != BCH_SB_SECTOR)
- sb_start = round_up(sb_start, block_size);
+ if (sb_pos != BCH_SB_SECTOR)
+ sb_pos = round_up(sb_pos, block_size);
- l->sb_offset[i] = cpu_to_le64(sb_start);
- sb_start += sb_size;
+ l->sb_offset[i] = cpu_to_le64(sb_pos);
+ sb_pos += sb_size;
}
- if (sb_start >= sb_end)
- die("insufficient space for superblocks");
+ if (sb_pos > sb_end)
+ die("insufficient space for superblocks: start %llu end %llu > %llu size %u",
+ sb_start, sb_pos, sb_end, sb_size);
}
void bch2_pick_bucket_size(struct bch_opts opts, struct dev_opts *dev)