fs: dcache scale d_unhashed
[linux-flexiantxendom0-natty.git] / arch / powerpc / platforms / cell / spufs / inode.c
index 6b7c7b1..5aef1a7 100644 (file)
@@ -95,9 +95,8 @@ spufs_new_inode(struct super_block *sb, int mode)
                goto out;
 
        inode->i_mode = mode;
-       inode->i_uid = current->fsuid;
-       inode->i_gid = current->fsgid;
-       inode->i_blocks = 0;
+       inode->i_uid = current_fsuid();
+       inode->i_gid = current_fsgid();
        inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
 out:
        return inode;
@@ -111,7 +110,9 @@ spufs_setattr(struct dentry *dentry, struct iattr *attr)
        if ((attr->ia_valid & ATTR_SIZE) &&
            (attr->ia_size != inode->i_size))
                return -EINVAL;
-       return inode_setattr(inode, attr);
+       setattr_copy(inode, attr);
+       mark_inode_dirty(inode);
+       return 0;
 }
 
 
@@ -120,7 +121,7 @@ spufs_new_file(struct super_block *sb, struct dentry *dentry,
                const struct file_operations *fops, int mode,
                size_t size, struct spu_context *ctx)
 {
-       static struct inode_operations spufs_file_iops = {
+       static const struct inode_operations spufs_file_iops = {
                .setattr = spufs_setattr,
        };
        struct inode *inode;
@@ -142,15 +143,14 @@ out:
 }
 
 static void
-spufs_delete_inode(struct inode *inode)
+spufs_evict_inode(struct inode *inode)
 {
        struct spufs_inode_info *ei = SPUFS_I(inode);
-
+       end_writeback(inode);
        if (ei->i_ctx)
                put_spu_context(ei->i_ctx);
        if (ei->i_gang)
                put_spu_gang(ei->i_gang);
-       clear_inode(inode);
 }
 
 static void spufs_prune_dir(struct dentry *dir)
@@ -162,10 +162,13 @@ static void spufs_prune_dir(struct dentry *dir)
                spin_lock(&dcache_lock);
                spin_lock(&dentry->d_lock);
                if (!(d_unhashed(dentry)) && dentry->d_inode) {
-                       dget_locked(dentry);
+                       dget_locked_dlock(dentry);
                        __d_drop(dentry);
                        spin_unlock(&dentry->d_lock);
                        simple_unlink(dir->d_inode, dentry);
+                       /* XXX: what is dcache_lock protecting here? Other
+                        * filesystems (IB, configfs) release dcache_lock
+                        * before unlink */
                        spin_unlock(&dcache_lock);
                        dput(dentry);
                } else {
@@ -187,8 +190,9 @@ static int spufs_rmdir(struct inode *parent, struct dentry *dir)
        return simple_rmdir(parent, dir);
 }
 
-static int spufs_fill_dir(struct dentry *dir, struct spufs_tree_descr *files,
-                         int mode, struct spu_context *ctx)
+static int spufs_fill_dir(struct dentry *dir,
+               const struct spufs_tree_descr *files, int mode,
+               struct spu_context *ctx)
 {
        struct dentry *dentry, *tmp;
        int ret;
@@ -251,7 +255,7 @@ const struct file_operations spufs_context_fops = {
        .llseek         = dcache_dir_lseek,
        .read           = generic_read_dir,
        .readdir        = dcache_readdir,
-       .fsync          = simple_sync_file,
+       .fsync          = noop_fsync,
 };
 EXPORT_SYMBOL_GPL(spufs_context_fops);
 
@@ -323,7 +327,7 @@ static int spufs_context_open(struct dentry *dentry, struct vfsmount *mnt)
                goto out;
        }
 
-       filp = dentry_open(dentry, mnt, O_RDONLY);
+       filp = dentry_open(dentry, mnt, O_RDONLY, current_cred());
        if (IS_ERR(filp)) {
                put_unused_fd(ret);
                ret = PTR_ERR(filp);
@@ -562,7 +566,7 @@ static int spufs_gang_open(struct dentry *dentry, struct vfsmount *mnt)
                goto out;
        }
 
-       filp = dentry_open(dentry, mnt, O_RDONLY);
+       filp = dentry_open(dentry, mnt, O_RDONLY, current_cred());
        if (IS_ERR(filp)) {
                put_unused_fd(ret);
                ret = PTR_ERR(filp);
@@ -631,11 +635,7 @@ long spufs_create(struct nameidata *nd, unsigned int flags, mode_t mode,
        if (IS_ERR(dentry))
                goto out_dir;
 
-       ret = -EEXIST;
-       if (dentry->d_inode)
-               goto out_dput;
-
-       mode &= ~current->fs->umask;
+       mode &= ~current_umask();
 
        if (flags & SPU_CREATE_GANG)
                ret = spufs_create_gang(nd->path.dentry->d_inode,
@@ -648,8 +648,6 @@ long spufs_create(struct nameidata *nd, unsigned int flags, mode_t mode,
                fsnotify_mkdir(nd->path.dentry->d_inode, dentry);
        return ret;
 
-out_dput:
-       dput(dentry);
 out_dir:
        mutex_unlock(&nd->path.dentry->d_inode->i_mutex);
 out:
@@ -661,7 +659,7 @@ enum {
        Opt_uid, Opt_gid, Opt_mode, Opt_debug, Opt_err,
 };
 
-static match_table_t spufs_tokens = {
+static const match_table_t spufs_tokens = {
        { Opt_uid,   "uid=%d" },
        { Opt_gid,   "gid=%d" },
        { Opt_mode,  "mode=%o" },
@@ -779,12 +777,11 @@ static int
 spufs_fill_super(struct super_block *sb, void *data, int silent)
 {
        struct spufs_sb_info *info;
-       static struct super_operations s_ops = {
+       static const struct super_operations s_ops = {
                .alloc_inode = spufs_alloc_inode,
                .destroy_inode = spufs_destroy_inode,
                .statfs = simple_statfs,
-               .delete_inode = spufs_delete_inode,
-               .drop_inode = generic_delete_inode,
+               .evict_inode = spufs_evict_inode,
                .show_options = generic_show_options,
        };
 
@@ -804,17 +801,17 @@ spufs_fill_super(struct super_block *sb, void *data, int silent)
        return spufs_create_root(sb, data);
 }
 
-static int
-spufs_get_sb(struct file_system_type *fstype, int flags,
-               const char *name, void *data, struct vfsmount *mnt)
+static struct dentry *
+spufs_mount(struct file_system_type *fstype, int flags,
+               const char *name, void *data)
 {
-       return get_sb_single(fstype, flags, data, spufs_fill_super, mnt);
+       return mount_single(fstype, flags, data, spufs_fill_super);
 }
 
 static struct file_system_type spufs_type = {
        .owner = THIS_MODULE,
        .name = "spufs",
-       .get_sb = spufs_get_sb,
+       .mount = spufs_mount,
        .kill_sb = kill_litter_super,
 };