diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2014-07-23 23:37:06 -0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-08-19 11:52:16 -0400 |
commit | ff61d17c6324d1b483fbbc5144f09668c24ff60c (patch) | |
tree | 53f4d493f94b4909376d3278c656f4678d9451bd /fs | |
parent | 2c91943b5066314a8bb9f0a65584e5e4cd92ea63 (diff) |
Btrfs: Fix the problem that the replace destroys the seed filesystem
The seed filesystem was destroyed by the device replace, the reproduce
method is:
# mkfs.btrfs -f <dev0>
# btrfstune -S 1 <dev0>
# mount <dev0> <mnt>
# btrfs device add <dev1> <mnt>
# umount <mnt>
# mount <dev1> <mnt>
# btrfs replace start -f <dev0> <dev2> <mnt>
# umount <mnt>
# mount <dev0> <mnt>
It is because we erase the super block on the seed device. It is wrong,
we should not change anything on the seed device.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/volumes.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index da0e632a21fc..00c8efdcd1e5 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -1848,8 +1848,12 @@ void btrfs_rm_dev_replace_srcdev(struct btrfs_fs_info *fs_info, | |||
1848 | if (srcdev->bdev) { | 1848 | if (srcdev->bdev) { |
1849 | fs_info->fs_devices->open_devices--; | 1849 | fs_info->fs_devices->open_devices--; |
1850 | 1850 | ||
1851 | /* zero out the old super */ | 1851 | /* |
1852 | btrfs_scratch_superblock(srcdev); | 1852 | * zero out the old super if it is not writable |
1853 | * (e.g. seed device) | ||
1854 | */ | ||
1855 | if (srcdev->writeable) | ||
1856 | btrfs_scratch_superblock(srcdev); | ||
1853 | } | 1857 | } |
1854 | 1858 | ||
1855 | call_rcu(&srcdev->rcu, free_device); | 1859 | call_rcu(&srcdev->rcu, free_device); |