]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - fs/sysfs/mount.c
mm: Remove slab destructors from kmem_cache_create().
[net-next-2.6.git] / fs / sysfs / mount.c
index 23a48a38e6af01455575083f8242ef4538f76cac..fbc7b65fe26267d776a105f5d37f01627edf44a2 100644 (file)
@@ -19,27 +19,18 @@ struct vfsmount *sysfs_mount;
 struct super_block * sysfs_sb = NULL;
 struct kmem_cache *sysfs_dir_cachep;
 
-static void sysfs_clear_inode(struct inode *inode);
-
 static const struct super_operations sysfs_ops = {
        .statfs         = simple_statfs,
        .drop_inode     = sysfs_delete_inode,
-       .clear_inode    = sysfs_clear_inode,
 };
 
-static struct sysfs_dirent sysfs_root = {
-       .s_sibling      = LIST_HEAD_INIT(sysfs_root.s_sibling),
-       .s_children     = LIST_HEAD_INIT(sysfs_root.s_children),
-       .s_element      = NULL,
-       .s_type         = SYSFS_ROOT,
-       .s_iattr        = NULL,
+struct sysfs_dirent sysfs_root = {
+       .s_count        = ATOMIC_INIT(1),
+       .s_flags        = SYSFS_ROOT,
+       .s_mode         = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
+       .s_ino          = 1,
 };
 
-static void sysfs_clear_inode(struct inode *inode)
-{
-       kfree(inode->i_private);
-}
-
 static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
 {
        struct inode *inode;
@@ -52,24 +43,26 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
        sb->s_time_gran = 1;
        sysfs_sb = sb;
 
-       inode = sysfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
-                                &sysfs_root);
-       if (inode) {
-               inode->i_op = &sysfs_dir_inode_operations;
-               inode->i_fop = &sysfs_dir_operations;
-               /* directory inodes start off with i_nlink == 2 (for "." entry) */
-               inc_nlink(inode);
-       } else {
+       /* get root inode, initialize and unlock it */
+       inode = sysfs_get_inode(&sysfs_root);
+       if (!inode) {
                pr_debug("sysfs: could not get root inode\n");
                return -ENOMEM;
        }
 
+       inode->i_op = &sysfs_dir_inode_operations;
+       inode->i_fop = &sysfs_dir_operations;
+       inc_nlink(inode); /* directory, account for "." */
+       unlock_new_inode(inode);
+
+       /* instantiate and link root dentry */
        root = d_alloc_root(inode);
        if (!root) {
                pr_debug("%s: could not get root dentry!\n",__FUNCTION__);
                iput(inode);
                return -ENOMEM;
        }
+       sysfs_root.s_dentry = root;
        root->d_fsdata = &sysfs_root;
        sb->s_root = root;
        return 0;
@@ -93,7 +86,7 @@ int __init sysfs_init(void)
 
        sysfs_dir_cachep = kmem_cache_create("sysfs_dir_cache",
                                              sizeof(struct sysfs_dirent),
-                                             0, 0, NULL, NULL);
+                                             0, 0, NULL);
        if (!sysfs_dir_cachep)
                goto out;