[RFC 8/8] ext4: Let fs create the sysfs entries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx>

Another example of usage

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx>
---
 fs/ext4/ext4.h  |  3 ++-
 fs/ext4/super.c | 14 ++++++++------
 fs/ext4/sysfs.c | 39 +++++++--------------------------------
 3 files changed, 17 insertions(+), 39 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 349afeb..294d74d 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3165,8 +3165,9 @@ extern const struct inode_operations ext4_fast_symlink_inode_operations;
 /* sysfs.c */
 extern int ext4_register_sysfs(struct super_block *sb);
 extern void ext4_unregister_sysfs(struct super_block *sb);
-extern int __init ext4_init_sysfs(void);
+extern int __init ext4_init_sysfs(struct kset *kset);
 extern void ext4_exit_sysfs(void);
+extern struct kobj_type ext4_sb_ktype;
 
 /* block_validity */
 extern void ext4_release_system_zone(struct super_block *sb);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 304c712..be7c0ef 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5356,6 +5356,7 @@ static struct file_system_type ext4_fs_type = {
 	.mount		= ext4_mount,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	.sb_ktype	= &ext4_sb_ktype,
 };
 MODULE_ALIAS_FS("ext4");
 
@@ -5388,10 +5389,6 @@ static int __init ext4_init_fs(void)
 	if (err)
 		goto out4;
 
-	err = ext4_init_sysfs();
-	if (err)
-		goto out3;
-
 	err = ext4_init_mballoc();
 	if (err)
 		goto out2;
@@ -5402,18 +5399,23 @@ static int __init ext4_init_fs(void)
 	register_as_ext2();
 	err = register_filesystem(&ext4_fs_type);
 	if (err)
+		goto out0;
+
+	err = ext4_init_sysfs(ext4_fs_type.kset);
+	if (err)
 		goto out;
 
+
 	return 0;
 out:
+	unregister_filesystem(&ext4_fs_type);
+out0:
 	unregister_as_ext2();
 	unregister_as_ext3();
 	destroy_inodecache();
 out1:
 	ext4_exit_mballoc();
 out2:
-	ext4_exit_sysfs();
-out3:
 	ext4_exit_system_zone();
 out4:
 	ext4_exit_pageio();
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index 1420a3c..94390d0 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -329,28 +329,18 @@ static const struct sysfs_ops ext4_attr_ops = {
 	.store	= ext4_attr_store,
 };
 
-static struct kobj_type ext4_sb_ktype = {
+struct kobj_type ext4_sb_ktype = {
 	.default_attrs	= ext4_attrs,
 	.sysfs_ops	= &ext4_attr_ops,
 	.release	= ext4_sb_release,
 };
 
-static struct kobj_type ext4_ktype = {
-	.sysfs_ops	= &ext4_attr_ops,
-};
-
-static struct kset ext4_kset = {
-	.kobj   = {.ktype = &ext4_ktype},
-};
-
 static struct kobj_type ext4_feat_ktype = {
 	.default_attrs	= ext4_feat_attrs,
 	.sysfs_ops	= &ext4_attr_ops,
 };
 
-static struct kobject ext4_feat = {
-	.kset	= &ext4_kset,
-};
+static struct kobject ext4_feat;
 
 #define PROC_FILE_SHOW_DEFN(name) \
 static int name##_open(struct inode *inode, struct file *file) \
@@ -386,14 +376,6 @@ int ext4_register_sysfs(struct super_block *sb)
 {
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	struct ext4_proc_files *p;
-	int err;
-
-	sbi->s_kobj.kset = &ext4_kset;
-	init_completion(&sbi->s_kobj_unregister);
-	err = kobject_init_and_add(&sbi->s_kobj, &ext4_sb_ktype, NULL,
-				   "%s", sb->s_id);
-	if (err)
-		return err;
 
 	if (ext4_proc_root)
 		sbi->s_proc = proc_mkdir(sb->s_id, ext4_proc_root);
@@ -419,29 +401,22 @@ void ext4_unregister_sysfs(struct super_block *sb)
 	kobject_del(&sbi->s_kobj);
 }
 
-int __init ext4_init_sysfs(void)
+int __init ext4_init_sysfs(struct kset *kset)
 {
 	int ret;
 
-	kobject_set_name(&ext4_kset.kobj, "ext4");
-	ext4_kset.kobj.parent = fs_kobj;
-	ret = kset_register(&ext4_kset);
-	if (ret)
-		return ret;
-
+	ext4_feat.kset = kset;
 	ret = kobject_init_and_add(&ext4_feat, &ext4_feat_ktype,
 				   NULL, "features");
 	if (ret)
-		kset_unregister(&ext4_kset);
-	else
-		ext4_proc_root = proc_mkdir(proc_dirname, NULL);
-	return ret;
+		return ret;
+	ext4_proc_root = proc_mkdir(proc_dirname, NULL);
+	return 0;
 }
 
 void ext4_exit_sysfs(void)
 {
 	kobject_put(&ext4_feat);
-	kset_unregister(&ext4_kset);
 	remove_proc_entry(proc_dirname, NULL);
 	ext4_proc_root = NULL;
 }
-- 
2.6.6

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux