Skip to content

Commit 313b085

Browse files
josefbacikkdave
authored andcommitted
btrfs: move btrfs_scratch_superblocks into btrfs_dev_replace_finishing
We need to move the closing of the src_device out of all the device replace locking, but we definitely want to zero out the superblock before we commit the last time to make sure the device is properly removed. Handle this by pushing btrfs_scratch_superblocks into btrfs_dev_replace_finishing, and then later on we'll move the src_device closing and freeing stuff where we need it to be. Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent b5ddcff commit 313b085

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

fs/btrfs/dev-replace.c

+3
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,9 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
745745
/* replace the sysfs entry */
746746
btrfs_sysfs_remove_devices_dir(fs_info->fs_devices, src_device);
747747
btrfs_sysfs_update_devid(tgt_device);
748+
if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &src_device->dev_state))
749+
btrfs_scratch_superblocks(fs_info, src_device->bdev,
750+
src_device->name->str);
748751
btrfs_rm_dev_replace_free_srcdev(src_device);
749752

750753
/* write back the superblocks */

fs/btrfs/volumes.c

+3-9
Original file line numberDiff line numberDiff line change
@@ -1999,9 +1999,9 @@ static u64 btrfs_num_devices(struct btrfs_fs_info *fs_info)
19991999
return num_devices;
20002000
}
20012001

2002-
static void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,
2003-
struct block_device *bdev,
2004-
const char *device_path)
2002+
void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,
2003+
struct block_device *bdev,
2004+
const char *device_path)
20052005
{
20062006
struct btrfs_super_block *disk_super;
20072007
int copy_num;
@@ -2224,12 +2224,6 @@ void btrfs_rm_dev_replace_free_srcdev(struct btrfs_device *srcdev)
22242224
struct btrfs_fs_info *fs_info = srcdev->fs_info;
22252225
struct btrfs_fs_devices *fs_devices = srcdev->fs_devices;
22262226

2227-
if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &srcdev->dev_state)) {
2228-
/* zero out the old super if it is writable */
2229-
btrfs_scratch_superblocks(fs_info, srcdev->bdev,
2230-
srcdev->name->str);
2231-
}
2232-
22332227
btrfs_close_bdev(srcdev);
22342228
synchronize_rcu();
22352229
btrfs_free_device(srcdev);

fs/btrfs/volumes.h

+3
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,9 @@ void btrfs_set_fs_info_ptr(struct btrfs_fs_info *fs_info);
573573
void btrfs_reset_fs_info_ptr(struct btrfs_fs_info *fs_info);
574574
bool btrfs_check_rw_degradable(struct btrfs_fs_info *fs_info,
575575
struct btrfs_device *failing_dev);
576+
void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,
577+
struct block_device *bdev,
578+
const char *device_path);
576579

577580
int btrfs_bg_type_to_factor(u64 flags);
578581
const char *btrfs_bg_type_to_raid_name(u64 flags);

0 commit comments

Comments
 (0)