]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
fix init_layout()
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 20 Dec 2021 02:55:09 +0000 (21:55 -0500)
committerKent Overstreet <kent.overstreet@gmail.com>
Mon, 20 Dec 2021 02:55:09 +0000 (21:55 -0500)
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>
libbcachefs.c

index 85523c62064a12ede6ff37df9bac54eeea93a667..74a38f83c41c04abc4709cb9c39792577cddee15 100644 (file)
@@ -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)