aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-04-28 19:35:16 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2016-05-02 19:51:17 -0400
commit9cf843e3f47c41440367062e92ab32e59ecb6a87 (patch)
treec661c0dde1141aee43d8d406bd573d4ffcaafa95 /fs/namei.c
parentlookup_open(): put the dentry fed to ->lookup() or ->atomic_open() into in-lookup hash (diff)
downloadlinux-dev-9cf843e3f47c41440367062e92ab32e59ecb6a87.tar.xz
linux-dev-9cf843e3f47c41440367062e92ab32e59ecb6a87.zip
lookup_open(): lock the parent shared unless O_CREAT is given
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/namei.c b/fs/namei.c
index b84e6b2e19e9..01069ddda3e3 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3084,7 +3084,7 @@ static int do_last(struct nameidata *nd,
}
retry_lookup:
- if (op->open_flag & (O_CREAT | O_TRUNC | O_WRONLY | O_RDWR)) {
+ if (open_flag & (O_CREAT | O_TRUNC | O_WRONLY | O_RDWR)) {
error = mnt_want_write(nd->path.mnt);
if (!error)
got_write = true;
@@ -3094,9 +3094,15 @@ retry_lookup:
* dropping this one anyway.
*/
}
- inode_lock(dir->d_inode);
+ if (open_flag & O_CREAT)
+ inode_lock(dir->d_inode);
+ else
+ inode_lock_shared(dir->d_inode);
error = lookup_open(nd, &path, file, op, got_write, opened);
- inode_unlock(dir->d_inode);
+ if (open_flag & O_CREAT)
+ inode_unlock(dir->d_inode);
+ else
+ inode_unlock_shared(dir->d_inode);
if (error <= 0) {
if (error)