Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / arch / powerpc / platforms / cell / spufs / inode.c
index d955419..3950ddc 100644 (file)
@@ -82,7 +82,6 @@ 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:
@@ -120,7 +119,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 +156,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 +190,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);
 }
 
@@ -305,6 +303,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 +326,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 +435,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 = {