Skip to content

Commit ff61d17

Browse files
Miao Xiemasoncl
authored andcommitted
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 <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent 2c91943 commit ff61d17

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/btrfs/volumes.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,8 +1848,12 @@ void btrfs_rm_dev_replace_srcdev(struct btrfs_fs_info *fs_info,
18481848
if (srcdev->bdev) {
18491849
fs_info->fs_devices->open_devices--;
18501850

1851-
/* zero out the old super */
1852-
btrfs_scratch_superblock(srcdev);
1851+
/*
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);
18531857
}
18541858

18551859
call_rcu(&srcdev->rcu, free_device);

0 commit comments

Comments
 (0)