]> git.karo-electronics.de Git - linux-beck.git/commitdiff
Btrfs: sysfs: add pointer to access fs_info from fs_devices
authorAnand Jain <Anand.Jain@oracle.com>
Mon, 9 Mar 2015 22:38:31 +0000 (06:38 +0800)
committerDavid Sterba <dsterba@suse.cz>
Wed, 27 May 2015 10:27:21 +0000 (12:27 +0200)
adds fs_info pointer with struct btrfs_fs_devices.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
fs/btrfs/sysfs.c
fs/btrfs/volumes.c
fs/btrfs/volumes.h

index f045c568b3603f5b492a7adb1a7fad00d712ab58..4b9a8df3faea0c86519150edddfea3a2e874eb01 100644 (file)
@@ -530,6 +530,8 @@ static void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
 
 void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
 {
+       btrfs_reset_fs_info_ptr(fs_info);
+
        if (fs_info->space_info_kobj) {
                sysfs_remove_files(fs_info->space_info_kobj, allocation_attrs);
                kobject_del(fs_info->space_info_kobj);
@@ -729,6 +731,8 @@ int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
        struct btrfs_fs_devices *fs_devs = fs_info->fs_devices;
        struct kobject *super_kobj = &fs_devs->super_kobj;
 
+       btrfs_set_fs_info_ptr(fs_info);
+
        error = btrfs_sysfs_add_fsid(fs_devs, NULL);
        if (error)
                return error;
index e500bfa54dc9bfa7cbaae08ef9f052f0e7cff1c8..5719470b50cda355a4f41ce590dabadcc3fce9c6 100644 (file)
@@ -6733,3 +6733,21 @@ void btrfs_update_commit_device_bytes_used(struct btrfs_root *root,
        }
        unlock_chunks(root);
 }
+
+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;
+       }
+}
index ac7e938c6977593e498cd7646cfef124cdd4095a..210a64390f400915cb623ff8a4fd02738859a1a5 100644 (file)
@@ -254,6 +254,7 @@ struct btrfs_fs_devices {
         */
        int rotating;
 
+       struct btrfs_fs_info *fs_info;
        /* sysfs kobjects */
        struct kobject super_kobj;
        struct kobject *device_dir_kobj;
@@ -543,5 +544,7 @@ static inline void unlock_chunks(struct btrfs_root *root)
 }
 
 struct list_head *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);
 
 #endif