diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-04-28 18:50:59 +0300 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-05-03 02:51:16 +0300 |
commit | 6fbd07146d99239547cd4970622c96e9cb0f3213 (patch) | |
tree | 446ef0f6671c1d5f9a9d921d3c875a7394ed0256 /fs/namei.c | |
parent | 12fa5e240419237d848abe3d40809eabe9e8f4ca (diff) | |
download | linux-6fbd07146d99239547cd4970622c96e9cb0f3213.tar.xz |
lookup_open(): put the dentry fed to ->lookup() or ->atomic_open() into in-lookup hash
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r-- | fs/namei.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/fs/namei.c b/fs/namei.c index b9dde8490318..b84e6b2e19e9 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2842,6 +2842,7 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry, error = dir->i_op->atomic_open(dir, dentry, file, open_to_namei_flags(open_flag), mode, opened); + d_lookup_done(dentry); if (!error) { /* * We didn't have the inode before the open, so check open @@ -2903,23 +2904,36 @@ static int lookup_open(struct nameidata *nd, struct path *path, int open_flag = op->open_flag; struct dentry *dentry; int error, create_error = 0; - bool need_lookup = false; umode_t mode = op->mode; + DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); if (unlikely(IS_DEADDIR(dir_inode))) return -ENOENT; *opened &= ~FILE_CREATED; - dentry = lookup_dcache(&nd->last, dir, nd->flags); - if (IS_ERR(dentry)) - return PTR_ERR(dentry); + dentry = d_lookup(dir, &nd->last); + for (;;) { + if (!dentry) { + dentry = d_alloc_parallel(dir, &nd->last, &wq); + if (IS_ERR(dentry)) + return PTR_ERR(dentry); + } + if (d_in_lookup(dentry)) + break; - if (!dentry) { - dentry = d_alloc(dir, &nd->last); - if (unlikely(!dentry)) - return -ENOMEM; - need_lookup = true; - } else if (dentry->d_inode) { + if (!(dentry->d_flags & DCACHE_OP_REVALIDATE)) + break; + + error = d_revalidate(dentry, nd->flags); + if (likely(error > 0)) + break; + if (error) + goto out_dput; + d_invalidate(dentry); + dput(dentry); + dentry = NULL; + } + if (dentry->d_inode) { /* Cached positive dentry: will open in f_op->open */ goto out_no_open; } @@ -2968,9 +2982,10 @@ static int lookup_open(struct nameidata *nd, struct path *path, } no_open: - if (need_lookup) { + if (d_in_lookup(dentry)) { struct dentry *res = dir_inode->i_op->lookup(dir_inode, dentry, nd->flags); + d_lookup_done(dentry); if (unlikely(res)) { if (IS_ERR(res)) { error = PTR_ERR(res); |