btrfs-progs: add ask_user confirmation for btrfstune clear seeding flag
authorGui Hecheng <guihc.fnst@cn.fujitsu.com>
Mon, 7 Jul 2014 01:54:52 +0000 (09:54 +0800)
committerDavid Sterba <dsterba@suse.cz>
Fri, 22 Aug 2014 14:09:55 +0000 (16:09 +0200)
commit3db4c0a3d35dd5f81a4c1d405ef7f3ca3357ae03
tree196cad3ced3fda970e511b41e5688387e9fcba45
parentcfee4bc139ccb0e1332ec5f108ecb9dd1932e451
btrfs-progs: add ask_user confirmation for btrfstune clear seeding flag

If we do the following:
# mkfs.btrfs -f <dev>
# mount <dev> <mnt>
# dd if=/dev/urandom of=<mnt>/data bs=1M count=100
# umount <dev>
# btrfstune -S 1 <dev>  <--- make seeding device
# mount <dev> <mnt>
# btrfs dev add -f <dev2> <mnt>
# umount <dev>
# btrfstune -S 0 <dev> <--- clear seeding flag
# mount <dev2> <mnt> <=== new device not mountable

When mounting the new device, btrfs will check whether
the seeding flag is set when try to open seeding device.
If the user clears the seeding flag of the seeding device,
the new device will not be mountable. Even set the seeding
flag back will not recovery this problem, because the generation
has been changed. So clear the seeding flag has the chance to
damage the derived new fs.

So I add user confirmation check when clearing seeding flag.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
btrfstune.c