kernfs: move the last knowledge of sysfs out from kernfs
Subsystems (3)
PATCH 1/1 kernfs: move the last knowledge of sysfs out from kernfs
There is still one residue of sysfs remaining: the sb_magic SYSFS_MAGIC. However this should be kernfs user specific, so this patch moves it out. Kerrnfs user should specify their magic number while mouting.
Signed-off-by Jianyu Zhan <[email protected]>
--- fs/kernfs/mount.c | 9 +++++---- fs/sysfs/mount.c | 4 +++- include/linux/kernfs.h | 10 ++++++---- kernel/cgroup.c | 4 +++- 4 files changed, 17 insertions(+), 10 deletions(-)
fs/kernfs/mount.c +5 -4
@@ -62,7 +62,7 @@ struct kernfs_root *kernfs_root_from_sb(struct super_block *sb)return NULL ; } -static int kernfs_fill_super (struct super_block *sb) +static int kernfs_fill_super (struct super_block *sb,void *data) {struct kernfs_super_info *info =kernfs_info (sb);struct inode *inode;
@@ -70,7 +70,7 @@ static int kernfs_fill_super(struct super_block *sb) sb->s_blocksize =PAGE_CACHE_SIZE ; sb->s_blocksize_bits =PAGE_CACHE_SHIFT ; - sb->s_magic =SYSFS_MAGIC ; + sb->s_magic = (unsigned long )data; sb->s_op = &kernfs_sops; sb->s_time_gran =1 ;
@@ -132,6 +132,7 @@ const void *kernfs_super_ns(struct super_block *sb)* @flags: mount flags specified for the mount * @root: kernfs_root of the hierarchy being mounted * @new_sb_created: tell the caller if we allocated a new superblock +* @private: any file system specifc private data * @ns: optional namespace tag of the mount * * This is to be called from each kernfs user's file_system_type->mount()
@@ -143,7 +144,7 @@ const void *kernfs_super_ns(struct super_block *sb)*/ struct dentry *kernfs_mount_ns (struct file_system_type *fs_type,int flags,struct kernfs_root *root,bool *new_sb_created, -const void *ns) +void *private,const void *ns) {struct super_block *sb;struct kernfs_super_info *info;
@@ -166,7 +167,7 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags, *new_sb_created = !sb->s_root;if (!sb->s_root) { - error =kernfs_fill_super (sb); + error =kernfs_fill_super (sb, private);if (error) {deactivate_locked_super (sb);return ERR_PTR (error);
fs/sysfs/mount.c +3 -1
@@ -13,6 +13,7 @@#define DEBUG #include <linux/fs.h> +#include <linux/magic.h> #include <linux/mount.h> #include <linux/init.h> #include <linux/user_namespace.h>
@@ -38,7 +39,8 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type, } ns =kobj_ns_grab_current (KOBJ_NS_TYPE_NET ); - root =kernfs_mount_ns (fs_type, flags, sysfs_root, &new_sb, ns); + root =kernfs_mount_ns (fs_type, flags, sysfs_root, + &new_sb, (void *)SYSFS_MAGIC , ns);if (IS_ERR (root) || !new_sb)kobj_ns_drop (KOBJ_NS_TYPE_NET , ns);return root;
include/linux/kernfs.h +6 -4
@@ -281,7 +281,7 @@ void kernfs_notify(struct kernfs_node *kn);const void *kernfs_super_ns (struct super_block *sb);struct dentry *kernfs_mount_ns (struct file_system_type *fs_type,int flags,struct kernfs_root *root,bool *new_sb_created, -const void *ns); +void *private,const void *ns);void kernfs_kill_sb (struct super_block *sb);void kernfs_init (void );
@@ -374,7 +374,8 @@ static inline const void *kernfs_super_ns(struct super_block *sb)static inline struct dentry *kernfs_mount_ns (struct file_system_type *fs_type,int flags, -struct kernfs_root *root,bool *new_sb_created,const void *ns) +struct kernfs_root *root,bool *new_sb_created, +void *private,const void *ns) {return ERR_PTR (-ENOSYS ); }static inline void kernfs_kill_sb (struct super_block *sb) { }
@@ -432,9 +433,10 @@ static inline int kernfs_rename(struct kernfs_node *kn,static inline struct dentry *kernfs_mount (struct file_system_type *fs_type,int flags, -struct kernfs_root *root,bool *new_sb_created) +struct kernfs_root *root,bool *new_sb_created,void *private) { -return kernfs_mount_ns (fs_type, flags, root, new_sb_created,NULL ); +return kernfs_mount_ns (fs_type, flags, root, + new_sb_created, private,NULL ); }#endif /* __LINUX_KERNFS_H */
kernel/cgroup.c +3 -1
@@ -33,6 +33,7 @@#include <linux/init_task.h> #include <linux/kernel.h> #include <linux/list.h> +#include <linux/magic.h> #include <linux/mm.h> #include <linux/mutex.h> #include <linux/mount.h>
@@ -1604,7 +1605,8 @@ out_unlock:if (ret)return ERR_PTR (ret); - dentry =kernfs_mount (fs_type, flags, root->kf_root, &new_sb); + dentry =kernfs_mount (fs_type, flags, root->kf_root, + (void *)CGROUP_SUPER_MAGIC , &new_sb);if (IS_ERR (dentry) || !new_sb)cgroup_put (&root->cgrp);return dentry;
Signature · 1 line
1.9.0.GIT
Tejun Heo
maintainerHello,
fs/kernfs/mount.c const void *kernfs_super_ns(struct super_block *sb) · line 135
Quoted 5 lines · Jianyu Zhan
fs/kernfs/mount.c +1
-0@@ -132,6 +132,7 @@ const void *kernfs_super_ns(struct super_block *sb)* @flags: mount flags specified for the mount * @root: kernfs_root of the hierarchy being mounted * @new_sb_created: tell the caller if we allocated a new superblock +* @private: any file system specifc private data
Please put it before @new_sb_created. Also, why isn't it unsigned long magic?
Thanks.
Signature · 1 line
tejun
Hello,
fs/kernfs/mount.c const void *kernfs_super_ns(struct super_block *sb) · line 135
Quoted 5 lines · Jianyu Zhan
fs/kernfs/mount.c +1
-0@@ -132,6 +132,7 @@ const void *kernfs_super_ns(struct super_block *sb)* @flags: mount flags specified for the mount * @root: kernfs_root of the hierarchy being mounted * @new_sb_created: tell the caller if we allocated a new superblock +* @private: any file system specifc private data
Please put it before @new_sb_created. Also, why isn't it unsigned long magic?
Thanks.
Signature · 1 line
tejun