mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
[PATCH] r/o bind mount prepwork: move open_namei()'s vfs_create()
The code around vfs_create() in open_namei() is getting a bit too complex. Right now, there is at least the reference count on the dentry, and the i_mutex to worry about. Soon, we'll also have mnt_writecount. So, break the vfs_create() call out of open_namei(), and into a helper function. This duplicates the call to may_open(), but that isn't such a bad thing since the arguments (acc_mode and flag) were being heavily massaged anyway. Signed-off-by: Dave Hansen <haveblue@us.ibm.com> Acked-by: Christoph Hellwig <hch@lst.de> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
6902d925d5
commit
aab520e2f6
30
fs/namei.c
30
fs/namei.c
@ -1595,6 +1595,24 @@ int may_open(struct nameidata *nd, int acc_mode, int flag)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int open_namei_create(struct nameidata *nd, struct path *path,
|
||||
int flag, int mode)
|
||||
{
|
||||
int error;
|
||||
struct dentry *dir = nd->dentry;
|
||||
|
||||
if (!IS_POSIXACL(dir->d_inode))
|
||||
mode &= ~current->fs->umask;
|
||||
error = vfs_create(dir->d_inode, path->dentry, mode, nd);
|
||||
mutex_unlock(&dir->d_inode->i_mutex);
|
||||
dput(nd->dentry);
|
||||
nd->dentry = path->dentry;
|
||||
if (error)
|
||||
return error;
|
||||
/* Don't check for write permission, don't truncate */
|
||||
return may_open(nd, 0, flag & ~O_TRUNC);
|
||||
}
|
||||
|
||||
/*
|
||||
* open_namei()
|
||||
*
|
||||
@ -1676,18 +1694,10 @@ do_last:
|
||||
|
||||
/* Negative dentry, just create the file */
|
||||
if (!path.dentry->d_inode) {
|
||||
if (!IS_POSIXACL(dir->d_inode))
|
||||
mode &= ~current->fs->umask;
|
||||
error = vfs_create(dir->d_inode, path.dentry, mode, nd);
|
||||
mutex_unlock(&dir->d_inode->i_mutex);
|
||||
dput(nd->dentry);
|
||||
nd->dentry = path.dentry;
|
||||
error = open_namei_create(nd, &path, flag, mode);
|
||||
if (error)
|
||||
goto exit;
|
||||
/* Don't check for write permission, don't truncate */
|
||||
acc_mode = 0;
|
||||
flag &= ~O_TRUNC;
|
||||
goto ok;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user