Skip to contentSkip to conversation

btrfs-progs: enforce block count on all devices in mkfs

PATCH In review Josef Bacik 2 participants 2 messages Mar 28, 2012 – Mar 29, 2012 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: enforce block count on all devices in mkfs

I had a test that creates a 7gig raid1 device but it was ending up wonky because the second device that gets added is the full size of the disk instead of the limited size. So enforce the limited size on all disks passed in at mkfs time, otherwise our threshold calculations end up wonky when doing chunk allocations. Thanks,

---
 mkfs.c  |    1 +
 utils.c |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)
mkfs.c +1 -0
index c531ef2..6ae412f 100644
@@ -1404,6 +1404,7 @@ int main(int ac, char **av)
 			close(fd);
 			continue;
 		}
+		dev_block_count = block_count;
 		ret = btrfs_prepare_device(fd, file, zero_end,
 					   &dev_block_count, &mixed);
 		mixed = old_mixed;
utils.c +2 -0
index ee7fa1b..552233b 100644
@@ -555,6 +555,8 @@ int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret,
 		fprintf(stderr, "unable to find %s size\n", file);
 		exit(1);
 	}
+	if (*block_count_ret)
+		block_count = min(block_count, *block_count_ret);
 	zero_end = 1;
 
 	if (block_count < 1024 * 1024 * 1024 && !(*mixed)) {
Signature · 1 line
1.7.5.2