summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>2013-09-05 15:53:34 +0900
committerChris Mason <chris.mason@fusionio.com>2013-10-16 08:20:42 -0400
commitf9d102efdc87f9c142157f16e443fb2c610c5317 (patch)
tree9c8358a04594b5bf9309199d571163ebcb8d966b
parent7c9074422aedb10d56b3db74041f06fd43951577 (diff)
btrfs-progs: error if device for mkfs is too small
Eric pointed out that mkfs abort if specified volume is too small: # truncate --size=2m testfile # ./mkfs.btrfs testfile : SMALL VOLUME: forcing mixed metadata/data groups mkfs.btrfs: volumes.c:852: btrfs_alloc_chunk: Assertion `!(ret)' failed. Aborted (core dumped) As the first step to fix problems around there, let mkfs to report error if the size of target volume is less than the size of the first system block group, BTRFS_MKFS_SYSTEM_GROUP_SIZE (= 4MB). Reported-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--mkfs.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/mkfs.c b/mkfs.c
index 6abd3f89..b442fc0a 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1513,6 +1513,11 @@ int main(int ac, char **av)
dev_block_count = block_count;
}
+ /* To create the first block group and chunk 0 in make_btrfs */
+ if (dev_block_count < BTRFS_MKFS_SYSTEM_GROUP_SIZE) {
+ fprintf(stderr, "device is too small to make filesystem\n");
+ exit(1);
+ }
blocks[0] = BTRFS_SUPER_INFO_OFFSET;
for (i = 1; i < 7; i++) {