Commit c4989c2f authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: simplify setting/clearing fs_info to btrfs_fs_devices

It makes no sense to have sysfs-related routines be responsible for
properly initialising the fs_info pointer of struct btrfs_fs_device.
Instead this can be streamlined by making it the responsibility of
btrfs_init_devices_late to initialize it. That function already
initializes fs_info of every individual device in btrfs_fs_devices.

As far as clearing it is concerned it makes sense to move it to
close_fs_devices. That function is only called when struct
btrfs_fs_devices is no longer in use - either for holding seeds or
main devices for a mounted filesystem.
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 54eed6ae
...@@ -939,8 +939,6 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info) ...@@ -939,8 +939,6 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)
{ {
struct kobject *fsid_kobj = &fs_info->fs_devices->fsid_kobj; struct kobject *fsid_kobj = &fs_info->fs_devices->fsid_kobj;
btrfs_reset_fs_info_ptr(fs_info);
sysfs_remove_link(fsid_kobj, "bdi"); sysfs_remove_link(fsid_kobj, "bdi");
if (fs_info->space_info_kobj) { if (fs_info->space_info_kobj) {
...@@ -1404,8 +1402,6 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info) ...@@ -1404,8 +1402,6 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
struct btrfs_fs_devices *fs_devs = fs_info->fs_devices; struct btrfs_fs_devices *fs_devs = fs_info->fs_devices;
struct kobject *fsid_kobj = &fs_devs->fsid_kobj; struct kobject *fsid_kobj = &fs_devs->fsid_kobj;
btrfs_set_fs_info_ptr(fs_info);
error = btrfs_sysfs_add_devices_dir(fs_devs, NULL); error = btrfs_sysfs_add_devices_dir(fs_devs, NULL);
if (error) if (error)
return error; return error;
......
...@@ -1173,6 +1173,7 @@ static void close_fs_devices(struct btrfs_fs_devices *fs_devices) ...@@ -1173,6 +1173,7 @@ static void close_fs_devices(struct btrfs_fs_devices *fs_devices)
WARN_ON(fs_devices->rw_devices); WARN_ON(fs_devices->rw_devices);
fs_devices->opened = 0; fs_devices->opened = 0;
fs_devices->seeding = false; fs_devices->seeding = false;
fs_devices->fs_info = NULL;
} }
void btrfs_close_devices(struct btrfs_fs_devices *fs_devices) void btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
...@@ -7201,6 +7202,7 @@ void btrfs_init_devices_late(struct btrfs_fs_info *fs_info) ...@@ -7201,6 +7202,7 @@ void btrfs_init_devices_late(struct btrfs_fs_info *fs_info)
device->fs_info = fs_info; device->fs_info = fs_info;
mutex_unlock(&fs_devices->device_list_mutex); mutex_unlock(&fs_devices->device_list_mutex);
fs_devices->fs_info = fs_info;
fs_devices = fs_devices->seed; fs_devices = fs_devices->seed;
} }
} }
...@@ -7499,24 +7501,6 @@ void btrfs_commit_device_sizes(struct btrfs_transaction *trans) ...@@ -7499,24 +7501,6 @@ void btrfs_commit_device_sizes(struct btrfs_transaction *trans)
mutex_unlock(&trans->fs_info->chunk_mutex); mutex_unlock(&trans->fs_info->chunk_mutex);
} }
void btrfs_set_fs_info_ptr(struct btrfs_fs_info *fs_info)
{
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
while (fs_devices) {
fs_devices->fs_info = fs_info;
fs_devices = fs_devices->seed;
}
}
void btrfs_reset_fs_info_ptr(struct btrfs_fs_info *fs_info)
{
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
while (fs_devices) {
fs_devices->fs_info = NULL;
fs_devices = fs_devices->seed;
}
}
/* /*
* Multiplicity factor for simple profiles: DUP, RAID1-like and RAID10. * Multiplicity factor for simple profiles: DUP, RAID1-like and RAID10.
*/ */
......
...@@ -569,8 +569,6 @@ static inline enum btrfs_raid_types btrfs_bg_flags_to_raid_index(u64 flags) ...@@ -569,8 +569,6 @@ static inline enum btrfs_raid_types btrfs_bg_flags_to_raid_index(u64 flags)
void btrfs_commit_device_sizes(struct btrfs_transaction *trans); void btrfs_commit_device_sizes(struct btrfs_transaction *trans);
struct list_head * __attribute_const__ btrfs_get_fs_uuids(void); struct list_head * __attribute_const__ btrfs_get_fs_uuids(void);
void btrfs_set_fs_info_ptr(struct btrfs_fs_info *fs_info);
void btrfs_reset_fs_info_ptr(struct btrfs_fs_info *fs_info);
bool btrfs_check_rw_degradable(struct btrfs_fs_info *fs_info, bool btrfs_check_rw_degradable(struct btrfs_fs_info *fs_info,
struct btrfs_device *failing_dev); struct btrfs_device *failing_dev);
void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info, void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,
......
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