Skip to content

Commit

Permalink
Btrfs: Fix the problem that the replace destroys the seed filesystem
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Miao Xie authored and Chris Mason committed Aug 19, 2014
1 parent 2c91943 commit ff61d17
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1848,8 +1848,12 @@ void btrfs_rm_dev_replace_srcdev(struct btrfs_fs_info *fs_info,
if (srcdev->bdev) {
fs_info->fs_devices->open_devices--;

/* zero out the old super */
btrfs_scratch_superblock(srcdev);
/*
* zero out the old super if it is not writable
* (e.g. seed device)
*/
if (srcdev->writeable)
btrfs_scratch_superblock(srcdev);
}

call_rcu(&srcdev->rcu, free_device);
Expand Down

0 comments on commit ff61d17

Please sign in to comment.