47 lines
1.4 KiB
Diff
47 lines
1.4 KiB
Diff
|
From 684d9a33f77967a9b50b597cece1b2b2e29d2b8d Mon Sep 17 00:00:00 2001
|
||
|
From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
|
||
|
Date: Thu, 5 Sep 2013 15:53:34 +0900
|
||
|
Subject: [PATCH 59/62] 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>
|
||
|
---
|
||
|
mkfs.c | 6 ++++++
|
||
|
1 file changed, 6 insertions(+)
|
||
|
|
||
|
diff --git a/mkfs.c b/mkfs.c
|
||
|
index 8a68f8a9f762..9a017c1dc95b 100644
|
||
|
--- a/mkfs.c
|
||
|
+++ b/mkfs.c
|
||
|
@@ -1400,6 +1400,12 @@ int main(int ac, char **av)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
+ /* 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++) {
|
||
|
blocks[i] = BTRFS_SUPER_INFO_OFFSET + 1024 * 1024 +
|
||
|
--
|
||
|
1.8.3.1
|
||
|
|