Btrfs: set right total device count for seeding support
authorWang Shilong <wangsl.fnst@cn.fujitsu.com>
Tue, 13 May 2014 09:05:06 +0000 (17:05 +0800)
committerJiri Slaby <jslaby@suse.cz>
Wed, 2 Jul 2014 10:06:38 +0000 (12:06 +0200)
commit9612bd1d820c62ec1f556ae5ba99191424fc1f16
tree570f28d07b08de1d122a9e702c3b7c589cc8e7bf
parentfbf046315fca47774f4843d74a58b4140d47bd16
Btrfs: set right total device count for seeding support

commit 298658414a2f0bea1f05a81876a45c1cd96aa2e0 upstream.

Seeding device support allows us to create a new filesystem
based on existed filesystem.

However newly created filesystem's @total_devices should include seed
devices. This patch fix the following problem:

 # mkfs.btrfs -f /dev/sdb
 # btrfstune -S 1 /dev/sdb
 # mount /dev/sdb /mnt
 # btrfs device add -f /dev/sdc /mnt --->fs_devices->total_devices = 1
 # umount /mnt
 # mount /dev/sdc /mnt               --->fs_devices->total_devices = 2

This is because we record right @total_devices in superblock, but
@fs_devices->total_devices is reset to be 0 in btrfs_prepare_sprout().

Fix this problem by not resetting @fs_devices->total_devices.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
fs/btrfs/volumes.c