aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorAnand Jain <anand.jain@oracle.com>2016-06-14 06:55:25 -0400
committerDavid Sterba <dsterba@suse.com>2016-07-26 07:52:25 -0400
commitf448341af9cf50b9f405f5192f184d398e1812e0 (patch)
tree22cc926c9f70a3b79fd7ab7be739752721c5f3cf /fs/btrfs
parentc8bb0c8bd22a4b9d1c457a9c2b1c192d8271831a (diff)
btrfs: reorg btrfs_close_one_device()
Moves closer to the caller and removes declaration 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.c71
1 files changed, 35 insertions, 36 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 589f128173b1..e54b3fe92e90 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -140,7 +140,6 @@ static int btrfs_relocate_sys_chunks(struct btrfs_root *root);
140static void __btrfs_reset_dev_stats(struct btrfs_device *dev); 140static void __btrfs_reset_dev_stats(struct btrfs_device *dev);
141static void btrfs_dev_stat_print_on_error(struct btrfs_device *dev); 141static void btrfs_dev_stat_print_on_error(struct btrfs_device *dev);
142static void btrfs_dev_stat_print_on_load(struct btrfs_device *device); 142static void btrfs_dev_stat_print_on_load(struct btrfs_device *device);
143static void btrfs_close_one_device(struct btrfs_device *device);
144 143
145DEFINE_MUTEX(uuid_mutex); 144DEFINE_MUTEX(uuid_mutex);
146static LIST_HEAD(fs_uuids); 145static LIST_HEAD(fs_uuids);
@@ -853,6 +852,41 @@ static void free_device(struct rcu_head *head)
853 schedule_work(&device->rcu_work); 852 schedule_work(&device->rcu_work);
854} 853}
855 854
855static void btrfs_close_one_device(struct btrfs_device *device)
856{
857 struct btrfs_fs_devices *fs_devices = device->fs_devices;
858 struct btrfs_device *new_device;
859 struct rcu_string *name;
860
861 if (device->bdev)
862 fs_devices->open_devices--;
863
864 if (device->writeable &&
865 device->devid != BTRFS_DEV_REPLACE_DEVID) {
866 list_del_init(&device->dev_alloc_list);
867 fs_devices->rw_devices--;
868 }
869
870 if (device->missing)
871 fs_devices->missing_devices--;
872
873 new_device = btrfs_alloc_device(NULL, &device->devid,
874 device->uuid);
875 BUG_ON(IS_ERR(new_device)); /* -ENOMEM */
876
877 /* Safe because we are under uuid_mutex */
878 if (device->name) {
879 name = rcu_string_strdup(device->name->str, GFP_NOFS);
880 BUG_ON(!name); /* -ENOMEM */
881 rcu_assign_pointer(new_device->name, name);
882 }
883
884 list_replace_rcu(&device->dev_list, &new_device->dev_list);
885 new_device->fs_devices = device->fs_devices;
886
887 call_rcu(&device->rcu, free_device);
888}
889
856static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices) 890static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
857{ 891{
858 struct btrfs_device *device, *tmp; 892 struct btrfs_device *device, *tmp;
@@ -7138,38 +7172,3 @@ void btrfs_reset_fs_info_ptr(struct btrfs_fs_info *fs_info)
7138 fs_devices = fs_devices->seed; 7172 fs_devices = fs_devices->seed;
7139 } 7173 }
7140} 7174}
7141
7142static void btrfs_close_one_device(struct btrfs_device *device)
7143{
7144 struct btrfs_fs_devices *fs_devices = device->fs_devices;
7145 struct btrfs_device *new_device;
7146 struct rcu_string *name;
7147
7148 if (device->bdev)
7149 fs_devices->open_devices--;
7150
7151 if (device->writeable &&
7152 device->devid != BTRFS_DEV_REPLACE_DEVID) {
7153 list_del_init(&device->dev_alloc_list);
7154 fs_devices->rw_devices--;
7155 }
7156
7157 if (device->missing)
7158 fs_devices->missing_devices--;
7159
7160 new_device = btrfs_alloc_device(NULL, &device->devid,
7161 device->uuid);
7162 BUG_ON(IS_ERR(new_device)); /* -ENOMEM */
7163
7164 /* Safe because we are under uuid_mutex */
7165 if (device->name) {
7166 name = rcu_string_strdup(device->name->str, GFP_NOFS);
7167 BUG_ON(!name); /* -ENOMEM */
7168 rcu_assign_pointer(new_device->name, name);
7169 }
7170
7171 list_replace_rcu(&device->dev_list, &new_device->dev_list);
7172 new_device->fs_devices = device->fs_devices;
7173
7174 call_rcu(&device->rcu, free_device);
7175}