aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-11-28 14:54:42 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-11-29 21:10:48 -0500
commitdf394fb56c64244b30b442e9e02de1a2d9c5a98b (patch)
treefc6b65c4356680c92df02c12ea0e386eeff9c992 /fs/sysfs
parentbc755553df9ab33f389c1a0a8bd0b4f4646e80ef (diff)
sysfs, kernfs: make super_blocks bind to different kernfs_roots
kernfs is being updated to allow multiple sysfs_dirent hierarchies so that it can also be used by other users. Currently, sysfs super_blocks are always attached to one kernfs_root - sysfs_root - and distinguished only by their namespace tags. This patch adds sysfs_super_info->root and update sysfs_fill/test_super() so that super_blocks are identified by the combination of both the associated kernfs_root and namespace tag. This allows mounting different kernfs hierarchies. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/sysfs')
-rw-r--r--fs/sysfs/mount.c10
-rw-r--r--fs/sysfs/sysfs.h6
2 files changed, 12 insertions, 4 deletions
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 0b5661b462f7..f143b203a7e6 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -37,6 +37,7 @@ struct sysfs_dirent *sysfs_root_sd;
37 37
38static int sysfs_fill_super(struct super_block *sb) 38static int sysfs_fill_super(struct super_block *sb)
39{ 39{
40 struct sysfs_super_info *info = sysfs_info(sb);
40 struct inode *inode; 41 struct inode *inode;
41 struct dentry *root; 42 struct dentry *root;
42 43
@@ -48,7 +49,7 @@ static int sysfs_fill_super(struct super_block *sb)
48 49
49 /* get root inode, initialize and unlock it */ 50 /* get root inode, initialize and unlock it */
50 mutex_lock(&sysfs_mutex); 51 mutex_lock(&sysfs_mutex);
51 inode = sysfs_get_inode(sb, sysfs_root_sd); 52 inode = sysfs_get_inode(sb, info->root->sd);
52 mutex_unlock(&sysfs_mutex); 53 mutex_unlock(&sysfs_mutex);
53 if (!inode) { 54 if (!inode) {
54 pr_debug("sysfs: could not get root inode\n"); 55 pr_debug("sysfs: could not get root inode\n");
@@ -61,8 +62,8 @@ static int sysfs_fill_super(struct super_block *sb)
61 pr_debug("%s: could not get root dentry!\n", __func__); 62 pr_debug("%s: could not get root dentry!\n", __func__);
62 return -ENOMEM; 63 return -ENOMEM;
63 } 64 }
64 kernfs_get(sysfs_root_sd); 65 kernfs_get(info->root->sd);
65 root->d_fsdata = sysfs_root_sd; 66 root->d_fsdata = info->root->sd;
66 sb->s_root = root; 67 sb->s_root = root;
67 sb->s_d_op = &sysfs_dentry_ops; 68 sb->s_d_op = &sysfs_dentry_ops;
68 return 0; 69 return 0;
@@ -73,7 +74,7 @@ static int sysfs_test_super(struct super_block *sb, void *data)
73 struct sysfs_super_info *sb_info = sysfs_info(sb); 74 struct sysfs_super_info *sb_info = sysfs_info(sb);
74 struct sysfs_super_info *info = data; 75 struct sysfs_super_info *info = data;
75 76
76 return sb_info->ns == info->ns; 77 return sb_info->root == info->root && sb_info->ns == info->ns;
77} 78}
78 79
79static int sysfs_set_super(struct super_block *sb, void *data) 80static int sysfs_set_super(struct super_block *sb, void *data)
@@ -110,6 +111,7 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type,
110 if (!info) 111 if (!info)
111 return ERR_PTR(-ENOMEM); 112 return ERR_PTR(-ENOMEM);
112 113
114 info->root = sysfs_root;
113 info->ns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET); 115 info->ns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET);
114 116
115 sb = sget(fs_type, sysfs_test_super, sysfs_set_super, flags, info); 117 sb = sget(fs_type, sysfs_test_super, sysfs_set_super, flags, info);
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 2b217cef90be..93b4b68458ad 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -20,6 +20,12 @@
20 20
21struct sysfs_super_info { 21struct sysfs_super_info {
22 /* 22 /*
23 * The root associated with this super_block. Each super_block is
24 * identified by the root and ns it's associated with.
25 */
26 struct kernfs_root *root;
27
28 /*
23 * Each sb is associated with one namespace tag, currently the network 29 * Each sb is associated with one namespace tag, currently the network
24 * namespace of the task which mounted this sysfs instance. If multiple 30 * namespace of the task which mounted this sysfs instance. If multiple
25 * tags become necessary, make the following an array and compare 31 * tags become necessary, make the following an array and compare