diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-03-17 16:24:54 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-03-20 21:29:47 -0400 |
commit | b7c177fcd2022ca8572284deb8f9b6ab5730eafb (patch) | |
tree | fe4c55e5c504d6db8de36336ecd0b493a7f71c46 | |
parent | 81d44ed159e3e81f7e62cee2d0fe68aae0c95e78 (diff) |
configfs: kill configfs_sb
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/configfs/configfs_internal.h | 3 | ||||
-rw-r--r-- | fs/configfs/dir.c | 29 | ||||
-rw-r--r-- | fs/configfs/inode.c | 9 | ||||
-rw-r--r-- | fs/configfs/mount.c | 4 | ||||
-rw-r--r-- | fs/configfs/symlink.c | 6 |
5 files changed, 26 insertions, 25 deletions
diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h index 1b7fdc0a6a09..37121c2be110 100644 --- a/fs/configfs/configfs_internal.h +++ b/fs/configfs/configfs_internal.h | |||
@@ -63,7 +63,7 @@ extern struct kmem_cache *configfs_dir_cachep; | |||
63 | 63 | ||
64 | extern int configfs_is_root(struct config_item *item); | 64 | extern int configfs_is_root(struct config_item *item); |
65 | 65 | ||
66 | extern struct inode * configfs_new_inode(umode_t mode, struct configfs_dirent *); | 66 | extern struct inode * configfs_new_inode(umode_t mode, struct configfs_dirent *, struct super_block *); |
67 | extern int configfs_create(struct dentry *, umode_t mode, int (*init)(struct inode *)); | 67 | extern int configfs_create(struct dentry *, umode_t mode, int (*init)(struct inode *)); |
68 | extern int configfs_inode_init(void); | 68 | extern int configfs_inode_init(void); |
69 | extern void configfs_inode_exit(void); | 69 | extern void configfs_inode_exit(void); |
@@ -84,7 +84,6 @@ extern int configfs_pin_fs(void); | |||
84 | extern void configfs_release_fs(void); | 84 | extern void configfs_release_fs(void); |
85 | 85 | ||
86 | extern struct rw_semaphore configfs_rename_sem; | 86 | extern struct rw_semaphore configfs_rename_sem; |
87 | extern struct super_block * configfs_sb; | ||
88 | extern const struct file_operations configfs_dir_operations; | 87 | extern const struct file_operations configfs_dir_operations; |
89 | extern const struct file_operations configfs_file_operations; | 88 | extern const struct file_operations configfs_file_operations; |
90 | extern const struct file_operations bin_fops; | 89 | extern const struct file_operations bin_fops; |
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index b0fbcbeb03ee..54c59a7e37ce 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c | |||
@@ -1079,6 +1079,7 @@ int configfs_depend_item(struct configfs_subsystem *subsys, | |||
1079 | int ret; | 1079 | int ret; |
1080 | struct configfs_dirent *p, *root_sd, *subsys_sd = NULL; | 1080 | struct configfs_dirent *p, *root_sd, *subsys_sd = NULL; |
1081 | struct config_item *s_item = &subsys->su_group.cg_item; | 1081 | struct config_item *s_item = &subsys->su_group.cg_item; |
1082 | struct dentry *root; | ||
1082 | 1083 | ||
1083 | /* | 1084 | /* |
1084 | * Pin the configfs filesystem. This means we can safely access | 1085 | * Pin the configfs filesystem. This means we can safely access |
@@ -1093,9 +1094,10 @@ int configfs_depend_item(struct configfs_subsystem *subsys, | |||
1093 | * subsystem is really registered, and so we need to lock out | 1094 | * subsystem is really registered, and so we need to lock out |
1094 | * configfs_[un]register_subsystem(). | 1095 | * configfs_[un]register_subsystem(). |
1095 | */ | 1096 | */ |
1096 | mutex_lock(&configfs_sb->s_root->d_inode->i_mutex); | 1097 | root = configfs_mount->mnt_root; |
1098 | mutex_lock(&root->d_inode->i_mutex); | ||
1097 | 1099 | ||
1098 | root_sd = configfs_sb->s_root->d_fsdata; | 1100 | root_sd = root->d_fsdata; |
1099 | 1101 | ||
1100 | list_for_each_entry(p, &root_sd->s_children, s_sibling) { | 1102 | list_for_each_entry(p, &root_sd->s_children, s_sibling) { |
1101 | if (p->s_type & CONFIGFS_DIR) { | 1103 | if (p->s_type & CONFIGFS_DIR) { |
@@ -1129,7 +1131,7 @@ int configfs_depend_item(struct configfs_subsystem *subsys, | |||
1129 | out_unlock_dirent_lock: | 1131 | out_unlock_dirent_lock: |
1130 | spin_unlock(&configfs_dirent_lock); | 1132 | spin_unlock(&configfs_dirent_lock); |
1131 | out_unlock_fs: | 1133 | out_unlock_fs: |
1132 | mutex_unlock(&configfs_sb->s_root->d_inode->i_mutex); | 1134 | mutex_unlock(&root->d_inode->i_mutex); |
1133 | 1135 | ||
1134 | /* | 1136 | /* |
1135 | * If we succeeded, the fs is pinned via other methods. If not, | 1137 | * If we succeeded, the fs is pinned via other methods. If not, |
@@ -1543,6 +1545,7 @@ static inline unsigned char dt_type(struct configfs_dirent *sd) | |||
1543 | static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir) | 1545 | static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir) |
1544 | { | 1546 | { |
1545 | struct dentry *dentry = filp->f_path.dentry; | 1547 | struct dentry *dentry = filp->f_path.dentry; |
1548 | struct super_block *sb = dentry->d_sb; | ||
1546 | struct configfs_dirent * parent_sd = dentry->d_fsdata; | 1549 | struct configfs_dirent * parent_sd = dentry->d_fsdata; |
1547 | struct configfs_dirent *cursor = filp->private_data; | 1550 | struct configfs_dirent *cursor = filp->private_data; |
1548 | struct list_head *p, *q = &cursor->s_sibling; | 1551 | struct list_head *p, *q = &cursor->s_sibling; |
@@ -1605,7 +1608,7 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir | |||
1605 | ino = inode->i_ino; | 1608 | ino = inode->i_ino; |
1606 | spin_unlock(&configfs_dirent_lock); | 1609 | spin_unlock(&configfs_dirent_lock); |
1607 | if (!inode) | 1610 | if (!inode) |
1608 | ino = iunique(configfs_sb, 2); | 1611 | ino = iunique(sb, 2); |
1609 | 1612 | ||
1610 | if (filldir(dirent, name, len, filp->f_pos, ino, | 1613 | if (filldir(dirent, name, len, filp->f_pos, ino, |
1611 | dt_type(next)) < 0) | 1614 | dt_type(next)) < 0) |
@@ -1677,6 +1680,7 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys) | |||
1677 | struct config_group *group = &subsys->su_group; | 1680 | struct config_group *group = &subsys->su_group; |
1678 | struct qstr name; | 1681 | struct qstr name; |
1679 | struct dentry *dentry; | 1682 | struct dentry *dentry; |
1683 | struct dentry *root; | ||
1680 | struct configfs_dirent *sd; | 1684 | struct configfs_dirent *sd; |
1681 | 1685 | ||
1682 | err = configfs_pin_fs(); | 1686 | err = configfs_pin_fs(); |
@@ -1686,18 +1690,18 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys) | |||
1686 | if (!group->cg_item.ci_name) | 1690 | if (!group->cg_item.ci_name) |
1687 | group->cg_item.ci_name = group->cg_item.ci_namebuf; | 1691 | group->cg_item.ci_name = group->cg_item.ci_namebuf; |
1688 | 1692 | ||
1689 | sd = configfs_sb->s_root->d_fsdata; | 1693 | root = configfs_mount->mnt_root; |
1694 | sd = root->d_fsdata; | ||
1690 | link_group(to_config_group(sd->s_element), group); | 1695 | link_group(to_config_group(sd->s_element), group); |
1691 | 1696 | ||
1692 | mutex_lock_nested(&configfs_sb->s_root->d_inode->i_mutex, | 1697 | mutex_lock_nested(&root->d_inode->i_mutex, I_MUTEX_PARENT); |
1693 | I_MUTEX_PARENT); | ||
1694 | 1698 | ||
1695 | name.name = group->cg_item.ci_name; | 1699 | name.name = group->cg_item.ci_name; |
1696 | name.len = strlen(name.name); | 1700 | name.len = strlen(name.name); |
1697 | name.hash = full_name_hash(name.name, name.len); | 1701 | name.hash = full_name_hash(name.name, name.len); |
1698 | 1702 | ||
1699 | err = -ENOMEM; | 1703 | err = -ENOMEM; |
1700 | dentry = d_alloc(configfs_sb->s_root, &name); | 1704 | dentry = d_alloc(root, &name); |
1701 | if (dentry) { | 1705 | if (dentry) { |
1702 | d_add(dentry, NULL); | 1706 | d_add(dentry, NULL); |
1703 | 1707 | ||
@@ -1714,7 +1718,7 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys) | |||
1714 | } | 1718 | } |
1715 | } | 1719 | } |
1716 | 1720 | ||
1717 | mutex_unlock(&configfs_sb->s_root->d_inode->i_mutex); | 1721 | mutex_unlock(&root->d_inode->i_mutex); |
1718 | 1722 | ||
1719 | if (err) { | 1723 | if (err) { |
1720 | unlink_group(group); | 1724 | unlink_group(group); |
@@ -1728,13 +1732,14 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys) | |||
1728 | { | 1732 | { |
1729 | struct config_group *group = &subsys->su_group; | 1733 | struct config_group *group = &subsys->su_group; |
1730 | struct dentry *dentry = group->cg_item.ci_dentry; | 1734 | struct dentry *dentry = group->cg_item.ci_dentry; |
1735 | struct dentry *root = dentry->d_sb->s_root; | ||
1731 | 1736 | ||
1732 | if (dentry->d_parent != configfs_sb->s_root) { | 1737 | if (dentry->d_parent != root) { |
1733 | printk(KERN_ERR "configfs: Tried to unregister non-subsystem!\n"); | 1738 | printk(KERN_ERR "configfs: Tried to unregister non-subsystem!\n"); |
1734 | return; | 1739 | return; |
1735 | } | 1740 | } |
1736 | 1741 | ||
1737 | mutex_lock_nested(&configfs_sb->s_root->d_inode->i_mutex, | 1742 | mutex_lock_nested(&root->d_inode->i_mutex, |
1738 | I_MUTEX_PARENT); | 1743 | I_MUTEX_PARENT); |
1739 | mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD); | 1744 | mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD); |
1740 | mutex_lock(&configfs_symlink_mutex); | 1745 | mutex_lock(&configfs_symlink_mutex); |
@@ -1751,7 +1756,7 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys) | |||
1751 | 1756 | ||
1752 | d_delete(dentry); | 1757 | d_delete(dentry); |
1753 | 1758 | ||
1754 | mutex_unlock(&configfs_sb->s_root->d_inode->i_mutex); | 1759 | mutex_unlock(&root->d_inode->i_mutex); |
1755 | 1760 | ||
1756 | dput(dentry); | 1761 | dput(dentry); |
1757 | 1762 | ||
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c index 3ee36d418863..8cf21ef902fc 100644 --- a/fs/configfs/inode.c +++ b/fs/configfs/inode.c | |||
@@ -44,8 +44,6 @@ | |||
44 | static struct lock_class_key default_group_class[MAX_LOCK_DEPTH]; | 44 | static struct lock_class_key default_group_class[MAX_LOCK_DEPTH]; |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | extern struct super_block * configfs_sb; | ||
48 | |||
49 | static const struct address_space_operations configfs_aops = { | 47 | static const struct address_space_operations configfs_aops = { |
50 | .readpage = simple_readpage, | 48 | .readpage = simple_readpage, |
51 | .write_begin = simple_write_begin, | 49 | .write_begin = simple_write_begin, |
@@ -132,9 +130,10 @@ static inline void set_inode_attr(struct inode * inode, struct iattr * iattr) | |||
132 | inode->i_ctime = iattr->ia_ctime; | 130 | inode->i_ctime = iattr->ia_ctime; |
133 | } | 131 | } |
134 | 132 | ||
135 | struct inode *configfs_new_inode(umode_t mode, struct configfs_dirent * sd) | 133 | struct inode *configfs_new_inode(umode_t mode, struct configfs_dirent *sd, |
134 | struct super_block *s) | ||
136 | { | 135 | { |
137 | struct inode * inode = new_inode(configfs_sb); | 136 | struct inode * inode = new_inode(s); |
138 | if (inode) { | 137 | if (inode) { |
139 | inode->i_ino = get_next_ino(); | 138 | inode->i_ino = get_next_ino(); |
140 | inode->i_mapping->a_ops = &configfs_aops; | 139 | inode->i_mapping->a_ops = &configfs_aops; |
@@ -192,7 +191,7 @@ int configfs_create(struct dentry * dentry, umode_t mode, int (*init)(struct ino | |||
192 | if (dentry) { | 191 | if (dentry) { |
193 | if (!dentry->d_inode) { | 192 | if (!dentry->d_inode) { |
194 | struct configfs_dirent *sd = dentry->d_fsdata; | 193 | struct configfs_dirent *sd = dentry->d_fsdata; |
195 | if ((inode = configfs_new_inode(mode, sd))) { | 194 | if ((inode = configfs_new_inode(mode, sd, dentry->d_sb))) { |
196 | if (dentry->d_parent && dentry->d_parent->d_inode) { | 195 | if (dentry->d_parent && dentry->d_parent->d_inode) { |
197 | struct inode *p_inode = dentry->d_parent->d_inode; | 196 | struct inode *p_inode = dentry->d_parent->d_inode; |
198 | p_inode->i_mtime = p_inode->i_ctime = CURRENT_TIME; | 197 | p_inode->i_mtime = p_inode->i_ctime = CURRENT_TIME; |
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c index eb41adc28cfe..cc829fc85d77 100644 --- a/fs/configfs/mount.c +++ b/fs/configfs/mount.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #define CONFIGFS_MAGIC 0x62656570 | 38 | #define CONFIGFS_MAGIC 0x62656570 |
39 | 39 | ||
40 | struct vfsmount * configfs_mount = NULL; | 40 | struct vfsmount * configfs_mount = NULL; |
41 | struct super_block * configfs_sb = NULL; | ||
42 | struct kmem_cache *configfs_dir_cachep; | 41 | struct kmem_cache *configfs_dir_cachep; |
43 | static int configfs_mnt_count = 0; | 42 | static int configfs_mnt_count = 0; |
44 | 43 | ||
@@ -77,10 +76,9 @@ static int configfs_fill_super(struct super_block *sb, void *data, int silent) | |||
77 | sb->s_magic = CONFIGFS_MAGIC; | 76 | sb->s_magic = CONFIGFS_MAGIC; |
78 | sb->s_op = &configfs_ops; | 77 | sb->s_op = &configfs_ops; |
79 | sb->s_time_gran = 1; | 78 | sb->s_time_gran = 1; |
80 | configfs_sb = sb; | ||
81 | 79 | ||
82 | inode = configfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, | 80 | inode = configfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, |
83 | &configfs_root); | 81 | &configfs_root, sb); |
84 | if (inode) { | 82 | if (inode) { |
85 | inode->i_op = &configfs_root_inode_operations; | 83 | inode->i_op = &configfs_root_inode_operations; |
86 | inode->i_fop = &configfs_dir_operations; | 84 | inode->i_fop = &configfs_dir_operations; |
diff --git a/fs/configfs/symlink.c b/fs/configfs/symlink.c index 2817153d33c2..cc9f2546ea4a 100644 --- a/fs/configfs/symlink.c +++ b/fs/configfs/symlink.c | |||
@@ -110,13 +110,13 @@ out: | |||
110 | 110 | ||
111 | 111 | ||
112 | static int get_target(const char *symname, struct path *path, | 112 | static int get_target(const char *symname, struct path *path, |
113 | struct config_item **target) | 113 | struct config_item **target, struct super_block *sb) |
114 | { | 114 | { |
115 | int ret; | 115 | int ret; |
116 | 116 | ||
117 | ret = kern_path(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, path); | 117 | ret = kern_path(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, path); |
118 | if (!ret) { | 118 | if (!ret) { |
119 | if (path->dentry->d_sb == configfs_sb) { | 119 | if (path->dentry->d_sb == sb) { |
120 | *target = configfs_get_config_item(path->dentry); | 120 | *target = configfs_get_config_item(path->dentry); |
121 | if (!*target) { | 121 | if (!*target) { |
122 | ret = -ENOENT; | 122 | ret = -ENOENT; |
@@ -158,7 +158,7 @@ int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symna | |||
158 | !type->ct_item_ops->allow_link) | 158 | !type->ct_item_ops->allow_link) |
159 | goto out_put; | 159 | goto out_put; |
160 | 160 | ||
161 | ret = get_target(symname, &path, &target_item); | 161 | ret = get_target(symname, &path, &target_item, dentry->d_sb); |
162 | if (ret) | 162 | if (ret) |
163 | goto out_put; | 163 | goto out_put; |
164 | 164 | ||