diff options
author | Anand Jain <anand.jain@oracle.com> | 2013-08-30 16:50:37 +0800 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-10-16 08:20:03 -0400 |
commit | cdbc10729266c03aeb2eb812c17a3ef6c1ceae26 (patch) | |
tree | 07f8b91940f7436f143800be36f91dcd998c919d /utils.c | |
parent | 71d6bd3c8d70fb682c7fd50796f587ce1f1cf6f8 (diff) |
btrfs-progs: mkfs should check for small vol well before
This fix the regression introduced by 830427d
that it no more creates the FS if disk is small
and if no mixed option is provided.
This patch will bring it to the original design
which will force mixed profile when disk is small
and go ahead to create the FS.
Which also means that before we open the device
for the write we should also check if disk is small.
v2: fixes the checkpatch.pl warnings
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -1920,3 +1920,32 @@ int scan_for_btrfs(int where, int update_kernel) } return ret; } + +int is_vol_small(char *file) +{ + int fd = -1; + int e; + struct stat st; + u64 size; + + fd = open(file, O_RDONLY); + if (fd < 0) + return -errno; + if (fstat(fd, &st) < 0) { + e = -errno; + close(fd); + return e; + } + size = btrfs_device_size(fd, &st); + if (size == 0) { + close(fd); + return -1; + } + if (size < 1024 * 1024 * 1024) { + close(fd); + return 1; + } else { + close(fd); + return 0; + } +} |