pull unlock+dput() out into do_spu_create()

... and cleaning spufs_create() a bit, while we are at it

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2012-07-19 16:23:13 +04:00
parent 1ba44cc970
commit 25b2692a8a
2 changed files with 11 additions and 16 deletions

View File

@ -582,39 +582,32 @@ static struct file_system_type spufs_type;
long spufs_create(struct path *path, struct dentry *dentry, long spufs_create(struct path *path, struct dentry *dentry,
unsigned int flags, umode_t mode, struct file *filp) unsigned int flags, umode_t mode, struct file *filp)
{ {
struct inode *dir = path->dentry->d_inode;
int ret; int ret;
ret = -EINVAL;
/* check if we are on spufs */ /* check if we are on spufs */
if (path->dentry->d_sb->s_type != &spufs_type) if (path->dentry->d_sb->s_type != &spufs_type)
goto out; return -EINVAL;
/* don't accept undefined flags */ /* don't accept undefined flags */
if (flags & (~SPU_CREATE_FLAG_ALL)) if (flags & (~SPU_CREATE_FLAG_ALL))
goto out; return -EINVAL;
/* only threads can be underneath a gang */ /* only threads can be underneath a gang */
if (path->dentry != path->dentry->d_sb->s_root) { if (path->dentry != path->dentry->d_sb->s_root)
if ((flags & SPU_CREATE_GANG) || if ((flags & SPU_CREATE_GANG) || !SPUFS_I(dir)->i_gang)
!SPUFS_I(path->dentry->d_inode)->i_gang) return -EINVAL;
goto out;
}
mode &= ~current_umask(); mode &= ~current_umask();
if (flags & SPU_CREATE_GANG) if (flags & SPU_CREATE_GANG)
ret = spufs_create_gang(path->dentry->d_inode, ret = spufs_create_gang(dir, dentry, path->mnt, mode);
dentry, path->mnt, mode);
else else
ret = spufs_create_context(path->dentry->d_inode, ret = spufs_create_context(dir, dentry, path->mnt, flags, mode,
dentry, path->mnt, flags, mode,
filp); filp);
if (ret >= 0) if (ret >= 0)
fsnotify_mkdir(path->dentry->d_inode, dentry); fsnotify_mkdir(dir, dentry);
out:
mutex_unlock(&path->dentry->d_inode->i_mutex);
dput(dentry);
return ret; return ret;
} }

View File

@ -70,6 +70,8 @@ static long do_spu_create(const char __user *pathname, unsigned int flags,
ret = PTR_ERR(dentry); ret = PTR_ERR(dentry);
if (!IS_ERR(dentry)) { if (!IS_ERR(dentry)) {
ret = spufs_create(&path, dentry, flags, mode, neighbor); ret = spufs_create(&path, dentry, flags, mode, neighbor);
mutex_unlock(&path.dentry->d_inode->i_mutex);
dput(dentry);
path_put(&path); path_put(&path);
} }