summaryrefslogtreecommitdiff
path: root/fs/btrfs
diff options
context:
space:
mode:
authorAnand Jain <anand.jain@oracle.com>2018-04-12 10:29:31 +0800
committerDavid Sterba <dsterba@suse.com>2018-04-16 21:36:27 +0200
commit6ea967358ced7b9fc3b671e679233164d50d63af (patch)
treefea8f0fa3cf28dbbab3606b6d44bcde56d8ae98c /fs/btrfs
parenteaf9e1ecf09220d5998de1eaf3f6acfba59d6ed5 (diff)
downloadlinux-next-6ea967358ced7b9fc3b671e679233164d50d63af.tar.gz
btrfs: cleanup btrfs_rm_device() use cur_devices
Instead of de-referencing the device->fs_devices use cur_devices which points to the same fs_devices. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/volumes.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 44fbd4768fd0..9f5ae7920a87 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1983,20 +1983,25 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,
* (super_copy) should hold the device list mutex.
*/
+ /*
+ * In normal cases the cur_devices == fs_devices. But in case
+ * of deleting a seed device, the cur_devices should point to
+ * its own fs_devices listed under the fs_devices->seed.
+ */
cur_devices = device->fs_devices;
mutex_lock(&fs_devices->device_list_mutex);
list_del_rcu(&device->dev_list);
- device->fs_devices->num_devices--;
- device->fs_devices->total_devices--;
+ cur_devices->num_devices--;
+ cur_devices->total_devices--;
if (test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state))
- device->fs_devices->missing_devices--;
+ cur_devices->missing_devices--;
btrfs_assign_next_active_device(fs_info, device, NULL);
if (device->bdev) {
- device->fs_devices->open_devices--;
+ cur_devices->open_devices--;
/* remove sysfs entry */
btrfs_sysfs_rm_device_link(fs_devices, device);
}