diff options
-rw-r--r-- | fs/btrfs/volumes.c | 71 |
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); | |||
140 | static void __btrfs_reset_dev_stats(struct btrfs_device *dev); | 140 | static void __btrfs_reset_dev_stats(struct btrfs_device *dev); |
141 | static void btrfs_dev_stat_print_on_error(struct btrfs_device *dev); | 141 | static void btrfs_dev_stat_print_on_error(struct btrfs_device *dev); |
142 | static void btrfs_dev_stat_print_on_load(struct btrfs_device *device); | 142 | static void btrfs_dev_stat_print_on_load(struct btrfs_device *device); |
143 | static void btrfs_close_one_device(struct btrfs_device *device); | ||
144 | 143 | ||
145 | DEFINE_MUTEX(uuid_mutex); | 144 | DEFINE_MUTEX(uuid_mutex); |
146 | static LIST_HEAD(fs_uuids); | 145 | static 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 | ||
855 | static 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 | |||
856 | static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices) | 890 | static 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 | |||
7142 | static 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 | } | ||