aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Jain <Anand.Jain@oracle.com>2018-01-18 09:00:35 -0500
committerDavid Sterba <dsterba@suse.com>2018-01-22 14:25:48 -0500
commit522f1b45e41d893e4d1debd7f80c1e25e060c137 (patch)
tree1a39dffd709f946d5f2b6c2d197c37888f39357d
parent38cf665d338fca33af4b16f9ec7cad6637fc0fec (diff)
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: Anand Jain <anand.jain@oracle.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/volumes.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 207014fce7ea..9712377862d9 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -610,9 +610,6 @@ static void btrfs_free_stale_devices(struct btrfs_device *cur_dev)
610 struct btrfs_fs_devices *fs_devs, *tmp_fs_devs; 610 struct btrfs_fs_devices *fs_devs, *tmp_fs_devs;
611 struct btrfs_device *dev, *tmp_dev; 611 struct btrfs_device *dev, *tmp_dev;
612 612
613 if (!cur_dev->name)
614 return;
615
616 list_for_each_entry_safe(fs_devs, tmp_fs_devs, &fs_uuids, list) { 613 list_for_each_entry_safe(fs_devs, tmp_fs_devs, &fs_uuids, list) {
617 614
618 if (fs_devs->opened) 615 if (fs_devs->opened)
@@ -620,11 +617,9 @@ static void btrfs_free_stale_devices(struct btrfs_device *cur_dev)
620 617
621 list_for_each_entry_safe(dev, tmp_dev, 618 list_for_each_entry_safe(dev, tmp_dev,
622 &fs_devs->devices, dev_list) { 619 &fs_devs->devices, dev_list) {
623 int not_found; 620 int not_found = 0;
624 621
625 if (dev == cur_dev) 622 if (cur_dev && (cur_dev == dev || !dev->name))
626 continue;
627 if (!dev->name)
628 continue; 623 continue;
629 624
630 /* 625 /*
@@ -634,8 +629,9 @@ static void btrfs_free_stale_devices(struct btrfs_device *cur_dev)
634 * either use mapper or non mapper path throughout. 629 * either use mapper or non mapper path throughout.
635 */ 630 */
636 rcu_read_lock(); 631 rcu_read_lock();
637 not_found = strcmp(rcu_str_deref(dev->name), 632 if (cur_dev)
638 rcu_str_deref(cur_dev->name)); 633 not_found = strcmp(rcu_str_deref(dev->name),
634 rcu_str_deref(cur_dev->name));
639 rcu_read_unlock(); 635 rcu_read_unlock();
640 if (not_found) 636 if (not_found)
641 continue; 637 continue;