linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / arch / powerpc / platforms / cell / spufs / inode.c
index 3950ddc..b3962c3 100644 (file)
@@ -82,6 +82,7 @@ spufs_new_inode(struct super_block *sb, int mode)
        inode->i_mode = mode;
        inode->i_uid = current->fsuid;
        inode->i_gid = current->fsgid;
+       inode->i_blksize = PAGE_CACHE_SIZE;
        inode->i_blocks = 0;
        inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
 out:
@@ -102,7 +103,7 @@ spufs_setattr(struct dentry *dentry, struct iattr *attr)
 
 static int
 spufs_new_file(struct super_block *sb, struct dentry *dentry,
-               const struct file_operations *fops, int mode,
+               struct file_operations *fops, int mode,
                struct spu_context *ctx)
 {
        static struct inode_operations spufs_file_iops = {
@@ -119,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->i_private = SPUFS_I(inode)->i_ctx = get_spu_context(ctx);
+       inode->u.generic_ip = SPUFS_I(inode)->i_ctx = get_spu_context(ctx);
        d_add(dentry, inode);
 out:
        return ret;
@@ -156,12 +157,20 @@ 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);
 }
 
@@ -190,23 +199,16 @@ 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);
 }
 
@@ -239,7 +241,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();
+       ctx = alloc_spu_context(inode->i_mapping);
        SPUFS_I(inode)->i_ctx = ctx;
        if (!ctx)
                goto out_iput;
@@ -303,10 +305,6 @@ 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))
@@ -326,13 +324,8 @@ long spufs_create_thread(struct nameidata *nd,
         * in error path of *_open().
         */
        ret = spufs_context_open(dget(dentry), mntget(nd->mnt));
-       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;
-       }
+       if (ret < 0)
+               spufs_rmdir(nd->dentry->d_inode, dentry);
 
 out_dput:
        dput(dentry);
@@ -435,11 +428,11 @@ spufs_fill_super(struct super_block *sb, void *data, int silent)
        return spufs_create_root(sb, data);
 }
 
-static int
+static struct super_block *
 spufs_get_sb(struct file_system_type *fstype, int flags,
-               const char *name, void *data, struct vfsmount *mnt)
+               const char *name, void *data)
 {
-       return get_sb_single(fstype, flags, data, spufs_fill_super, mnt);
+       return get_sb_single(fstype, flags, data, spufs_fill_super);
 }
 
 static struct file_system_type spufs_type = {
@@ -449,7 +442,7 @@ static struct file_system_type spufs_type = {
        .kill_sb = kill_litter_super,
 };
 
-static int __init spufs_init(void)
+static int spufs_init(void)
 {
        int ret;
        ret = -ENOMEM;
@@ -479,7 +472,7 @@ out:
 }
 module_init(spufs_init);
 
-static void __exit spufs_exit(void)
+static void spufs_exit(void)
 {
        spu_sched_exit();
        unregister_spu_syscalls(&spufs_calls);