btrfs-progs: avoid write to the disk before sure to create fs
authorAnand Jain <anand.jain@oracle.com>
Wed, 7 Aug 2013 12:11:25 +0000 (20:11 +0800)
committerChris Mason <chris.mason@fusionio.com>
Wed, 16 Oct 2013 12:20:03 +0000 (08:20 -0400)
commit71d6bd3c8d70fb682c7fd50796f587ce1f1cf6f8
treefb05fe333eef75a04c056c8dfa2398e3175e1f19
parent1bef332a03c19c0142ffd48e061cac7bdd894e70
btrfs-progs: avoid write to the disk before sure to create fs

This patch provides fix for the following bug,

When mkfs.btrfs fails the disks shouldn't be written.
------------
btrfs fi show /dev/sdb
Label: none  uuid: 60fb76f4-3b4d-4632-a7da-6a44dea5573d
        Total devices 1 FS bytes used 24.00KiB
        devid    1 size 2.00GiB used 20.00MiB path /dev/sdb

mkfs.btrfs -dsingle -mraid1 /dev/sdb -f
::
unable to create FS with metadata profile 16 (have 1 devices)

btrfs fi show /dev/sdb
Label: none  uuid: 2da2179d-ecb1-4a4e-a44d-e7613a08c18d
        Total devices 1 FS bytes used 24.00KiB
        devid    1 size 2.00GiB used 20.00MiB path /dev/sdb
-------------

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>
mkfs.c
utils.c
utils.h