Skip to content

Commit 82372bc

Browse files
Miao Xiemasoncl
authored andcommitted
Btrfs: make the logic of source device removing more clear
Signed-off-by: Miao Xie <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent 67a2c45 commit 82372bc

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

fs/btrfs/dev-replace.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
569569
if (fs_info->fs_devices->latest_bdev == src_device->bdev)
570570
fs_info->fs_devices->latest_bdev = tgt_device->bdev;
571571
list_add(&tgt_device->dev_alloc_list, &fs_info->fs_devices->alloc_list);
572-
if (src_device->fs_devices->seeding)
573-
fs_info->fs_devices->rw_devices++;
572+
fs_info->fs_devices->rw_devices++;
574573

575574
/* replace the sysfs entry */
576575
btrfs_kobj_rm_device(fs_info, src_device);

fs/btrfs/volumes.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,23 +1819,18 @@ void btrfs_rm_dev_replace_srcdev(struct btrfs_fs_info *fs_info,
18191819
list_del_rcu(&srcdev->dev_list);
18201820
list_del_rcu(&srcdev->dev_alloc_list);
18211821
fs_devices->num_devices--;
1822-
if (srcdev->missing) {
1822+
if (srcdev->missing)
18231823
fs_devices->missing_devices--;
1824-
if (!fs_devices->seeding)
1825-
fs_devices->rw_devices++;
1824+
1825+
if (srcdev->writeable) {
1826+
fs_devices->rw_devices--;
1827+
/* zero out the old super if it is writable */
1828+
btrfs_scratch_superblock(srcdev);
18261829
}
18271830

1828-
if (srcdev->bdev) {
1831+
if (srcdev->bdev)
18291832
fs_devices->open_devices--;
18301833

1831-
/*
1832-
* zero out the old super if it is not writable
1833-
* (e.g. seed device)
1834-
*/
1835-
if (srcdev->writeable)
1836-
btrfs_scratch_superblock(srcdev);
1837-
}
1838-
18391834
call_rcu(&srcdev->rcu, free_device);
18401835

18411836
/*

0 commit comments

Comments
 (0)