[PATCH] inode_diet: Replace inode.u.generic_ip with inode.i_private
[pandora-kernel.git] / arch / powerpc / platforms / cell / spufs / inode.c
index b3962c3..b837f12 100644 (file)
@@ -103,7 +103,7 @@ spufs_setattr(struct dentry *dentry, struct iattr *attr)
 
 static int
 spufs_new_file(struct super_block *sb, struct dentry *dentry,
-               struct file_operations *fops, int mode,
+               const struct file_operations *fops, int mode,
                struct spu_context *ctx)
 {
        static struct inode_operations spufs_file_iops = {
@@ -120,7 +120,7 @@ spufs_new_file(struct super_block *sb, struct dentry *dentry,
        ret = 0;
        inode->i_op = &spufs_file_iops;
        inode->i_fop = fops;
-       inode->u.generic_ip = SPUFS_I(inode)->i_ctx = get_spu_context(ctx);
+       inode->i_private = SPUFS_I(inode)->i_ctx = get_spu_context(ctx);
        d_add(dentry, inode);
 out:
        return ret;
@@ -157,20 +157,12 @@ static void spufs_prune_dir(struct dentry *dir)
        mutex_unlock(&dir->d_inode->i_mutex);
 }
 
+/* Caller must hold root->i_mutex */
 static int spufs_rmdir(struct inode *root, struct dentry *dir_dentry)
 {
-       struct spu_context *ctx;
-
        /* remove all entries */
-       mutex_lock(&root->i_mutex);
        spufs_prune_dir(dir_dentry);
-       mutex_unlock(&root->i_mutex);
-
-       /* We have to give up the mm_struct */
-       ctx = SPUFS_I(dir_dentry->d_inode)->i_ctx;
-       spu_forget(ctx);
 
-       /* XXX Do we need to hold i_mutex here ? */
        return simple_rmdir(root, dir_dentry);
 }
 
@@ -199,16 +191,23 @@ out:
 
 static int spufs_dir_close(struct inode *inode, struct file *file)
 {
+       struct spu_context *ctx;
        struct inode *dir;
        struct dentry *dentry;
        int ret;
 
        dentry = file->f_dentry;
        dir = dentry->d_parent->d_inode;
+       ctx = SPUFS_I(dentry->d_inode)->i_ctx;
 
+       mutex_lock(&dir->i_mutex);
        ret = spufs_rmdir(dir, dentry);
+       mutex_unlock(&dir->i_mutex);
        WARN_ON(ret);
 
+       /* We have to give up the mm_struct */
+       spu_forget(ctx);
+
        return dcache_dir_close(inode, file);
 }
 
@@ -241,7 +240,7 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
                inode->i_gid = dir->i_gid;
                inode->i_mode &= S_ISGID;
        }
-       ctx = alloc_spu_context(inode->i_mapping);
+       ctx = alloc_spu_context();
        SPUFS_I(inode)->i_ctx = ctx;
        if (!ctx)
                goto out_iput;
@@ -305,6 +304,10 @@ long spufs_create_thread(struct nameidata *nd,
            nd->dentry != nd->dentry->d_sb->s_root)
                goto out;
 
+       /* all flags are reserved */
+       if (flags)
+               goto out;
+
        dentry = lookup_create(nd, 1);
        ret = PTR_ERR(dentry);
        if (IS_ERR(dentry))
@@ -324,8 +327,13 @@ long spufs_create_thread(struct nameidata *nd,
         * in error path of *_open().
         */
        ret = spufs_context_open(dget(dentry), mntget(nd->mnt));
-       if (ret < 0)
-               spufs_rmdir(nd->dentry->d_inode, dentry);
+       if (ret < 0) {
+               WARN_ON(spufs_rmdir(nd->dentry->d_inode, dentry));
+               mutex_unlock(&nd->dentry->d_inode->i_mutex);
+               spu_forget(SPUFS_I(dentry->d_inode)->i_ctx);
+               dput(dentry);
+               goto out;
+       }
 
 out_dput:
        dput(dentry);
@@ -428,11 +436,11 @@ spufs_fill_super(struct super_block *sb, void *data, int silent)
        return spufs_create_root(sb, data);
 }
 
-static struct super_block *
+static int
 spufs_get_sb(struct file_system_type *fstype, int flags,
-               const char *name, void *data)
+               const char *name, void *data, struct vfsmount *mnt)
 {
-       return get_sb_single(fstype, flags, data, spufs_fill_super);
+       return get_sb_single(fstype, flags, data, spufs_fill_super, mnt);
 }
 
 static struct file_system_type spufs_type = {
@@ -442,7 +450,7 @@ static struct file_system_type spufs_type = {
        .kill_sb = kill_litter_super,
 };
 
-static int spufs_init(void)
+static int __init spufs_init(void)
 {
        int ret;
        ret = -ENOMEM;
@@ -472,7 +480,7 @@ out:
 }
 module_init(spufs_init);
 
-static void spufs_exit(void)
+static void __exit spufs_exit(void)
 {
        spu_sched_exit();
        unregister_spu_syscalls(&spufs_calls);