From 2e7910d6ca359ff1dbe05b74e3d7f353b5b65362 Mon Sep 17 00:00:00 2001 From: Anand Jain Date: Tue, 10 Mar 2015 06:38:29 +0800 Subject: Btrfs: sysfs: move super_kobj and device_dir_kobj from fs_info to btrfs_fs_devices This patch will provide a framework and help to create attributes from the structure btrfs_fs_devices which are available even before fs_info is created. So by moving the parent kobject super_kobj from fs_info to btrfs_fs_devices, it will help to create attributes from the btrfs_fs_devices as well. Patches on top of this patch now will be able to create the sys/fs/btrfs/fsid kobject and attributes from btrfs_fs_devices when devices are scanned and registered to the kernel. Just to note, this does not change any of the existing btrfs sysfs external kobject names and its attributes and not even the life cycle of them. Changes are internal only. And to ensure the same, this path has been tested with various device operations and, checking and comparing the sysfs kobjects and attributes with sysfs kobject and attributes with out this patch, and they remain same. Signed-off-by: Anand Jain Signed-off-by: David Sterba --- fs/btrfs/volumes.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'fs/btrfs/volumes.h') diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index ebc31331a837..e9780e9e6d97 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -253,6 +253,11 @@ struct btrfs_fs_devices { * nonrot flag set */ int rotating; + + /* sysfs kobjects */ + struct kobject super_kobj; + struct kobject *device_dir_kobj; + struct completion kobj_unregister; }; #define BTRFS_BIO_INLINE_CSUM_SIZE 64 -- cgit v1.2.3 From c73eccf75bf92e49be30884da32a169b04eb5bc9 Mon Sep 17 00:00:00 2001 From: Anand Jain Date: Tue, 10 Mar 2015 06:38:30 +0800 Subject: Btrfs: introduce btrfs_get_fs_uuids to get fs_uuids Signed-off-by: Anand Jain Signed-off-by: David Sterba --- fs/btrfs/volumes.c | 4 ++++ fs/btrfs/volumes.h | 1 + 2 files changed, 5 insertions(+) (limited to 'fs/btrfs/volumes.h') diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 39ff99e4b5a6..e500bfa54dc9 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -52,6 +52,10 @@ static void btrfs_dev_stat_print_on_load(struct btrfs_device *device); DEFINE_MUTEX(uuid_mutex); static LIST_HEAD(fs_uuids); +struct list_head *btrfs_get_fs_uuids(void) +{ + return &fs_uuids; +} static struct btrfs_fs_devices *__alloc_fs_devices(void) { diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index e9780e9e6d97..ac7e938c6977 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -542,5 +542,6 @@ static inline void unlock_chunks(struct btrfs_root *root) mutex_unlock(&root->fs_info->chunk_mutex); } +struct list_head *btrfs_get_fs_uuids(void); #endif -- cgit v1.2.3 From 5a13f4308c5b4af28c01ca9cacdd8a6db777dfcb Mon Sep 17 00:00:00 2001 From: Anand Jain Date: Tue, 10 Mar 2015 06:38:31 +0800 Subject: Btrfs: sysfs: add pointer to access fs_info from fs_devices adds fs_info pointer with struct btrfs_fs_devices. Signed-off-by: Anand Jain Signed-off-by: David Sterba --- fs/btrfs/sysfs.c | 4 ++++ fs/btrfs/volumes.c | 18 ++++++++++++++++++ fs/btrfs/volumes.h | 3 +++ 3 files changed, 25 insertions(+) (limited to 'fs/btrfs/volumes.h') diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index f045c568b360..4b9a8df3faea 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -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; diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index e500bfa54dc9..5719470b50cd 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -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; + } +} diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index ac7e938c6977..210a64390f40 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -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 -- cgit v1.2.3