Commit 522f1b45 authored by Anand Jain's avatar Anand Jain Committed by David Sterba

btrfs: make btrfs_free_stale_devices() argument optional

This updates btrfs_free_stale_devices() helper function to delete all
unmouted devices, when arg is NULL.
Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
Reviewed-by: default avatarJosef Bacik <jbacik@fb.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 38cf665d
...@@ -610,9 +610,6 @@ static void btrfs_free_stale_devices(struct btrfs_device *cur_dev) ...@@ -610,9 +610,6 @@ static void btrfs_free_stale_devices(struct btrfs_device *cur_dev)
struct btrfs_fs_devices *fs_devs, *tmp_fs_devs; struct btrfs_fs_devices *fs_devs, *tmp_fs_devs;
struct btrfs_device *dev, *tmp_dev; struct btrfs_device *dev, *tmp_dev;
if (!cur_dev->name)
return;
list_for_each_entry_safe(fs_devs, tmp_fs_devs, &fs_uuids, list) { list_for_each_entry_safe(fs_devs, tmp_fs_devs, &fs_uuids, list) {
if (fs_devs->opened) if (fs_devs->opened)
...@@ -620,11 +617,9 @@ static void btrfs_free_stale_devices(struct btrfs_device *cur_dev) ...@@ -620,11 +617,9 @@ static void btrfs_free_stale_devices(struct btrfs_device *cur_dev)
list_for_each_entry_safe(dev, tmp_dev, list_for_each_entry_safe(dev, tmp_dev,
&fs_devs->devices, dev_list) { &fs_devs->devices, dev_list) {
int not_found; int not_found = 0;
if (dev == cur_dev) if (cur_dev && (cur_dev == dev || !dev->name))
continue;
if (!dev->name)
continue; continue;
/* /*
...@@ -634,8 +629,9 @@ static void btrfs_free_stale_devices(struct btrfs_device *cur_dev) ...@@ -634,8 +629,9 @@ static void btrfs_free_stale_devices(struct btrfs_device *cur_dev)
* either use mapper or non mapper path throughout. * either use mapper or non mapper path throughout.
*/ */
rcu_read_lock(); rcu_read_lock();
not_found = strcmp(rcu_str_deref(dev->name), if (cur_dev)
rcu_str_deref(cur_dev->name)); not_found = strcmp(rcu_str_deref(dev->name),
rcu_str_deref(cur_dev->name));
rcu_read_unlock(); rcu_read_unlock();
if (not_found) if (not_found)
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment