mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-01 12:04:08 +00:00
Btrfs: sysfs: separate device kobject and its attribute creation
Separate device kobject and its attribute creation so that device kobject can be created from the device discovery thread. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
0dd2906f72
commit
00c921c23f
1 changed files with 15 additions and 6 deletions
|
@ -645,6 +645,18 @@ int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int btrfs_sysfs_add_device(struct btrfs_fs_info *fs_info)
|
||||||
|
{
|
||||||
|
if (!fs_info->device_dir_kobj)
|
||||||
|
fs_info->device_dir_kobj = kobject_create_and_add("devices",
|
||||||
|
&fs_info->super_kobj);
|
||||||
|
|
||||||
|
if (!fs_info->device_dir_kobj)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info,
|
int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info,
|
||||||
struct btrfs_device *one_device)
|
struct btrfs_device *one_device)
|
||||||
{
|
{
|
||||||
|
@ -652,12 +664,9 @@ int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info,
|
||||||
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
|
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
|
||||||
struct btrfs_device *dev;
|
struct btrfs_device *dev;
|
||||||
|
|
||||||
if (!fs_info->device_dir_kobj)
|
error = btrfs_sysfs_add_device(fs_info);
|
||||||
fs_info->device_dir_kobj = kobject_create_and_add("devices",
|
if (error)
|
||||||
&fs_info->super_kobj);
|
return error;
|
||||||
|
|
||||||
if (!fs_info->device_dir_kobj)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
list_for_each_entry(dev, &fs_devices->devices, dev_list) {
|
list_for_each_entry(dev, &fs_devices->devices, dev_list) {
|
||||||
struct hd_struct *disk;
|
struct hd_struct *disk;
|
||||||
|
|
Loading…
Add table
Reference in a new issue