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>
This commit is contained in:
parent
12fa5e2404
commit
6fbd07146d
33
fs/namei.c
33
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,
|
error = dir->i_op->atomic_open(dir, dentry, file,
|
||||||
open_to_namei_flags(open_flag),
|
open_to_namei_flags(open_flag),
|
||||||
mode, opened);
|
mode, opened);
|
||||||
|
d_lookup_done(dentry);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
/*
|
/*
|
||||||
* We didn't have the inode before the open, so check open
|
* 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;
|
int open_flag = op->open_flag;
|
||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
int error, create_error = 0;
|
int error, create_error = 0;
|
||||||
bool need_lookup = false;
|
|
||||||
umode_t mode = op->mode;
|
umode_t mode = op->mode;
|
||||||
|
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
|
||||||
|
|
||||||
if (unlikely(IS_DEADDIR(dir_inode)))
|
if (unlikely(IS_DEADDIR(dir_inode)))
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
*opened &= ~FILE_CREATED;
|
*opened &= ~FILE_CREATED;
|
||||||
dentry = lookup_dcache(&nd->last, dir, nd->flags);
|
dentry = d_lookup(dir, &nd->last);
|
||||||
|
for (;;) {
|
||||||
|
if (!dentry) {
|
||||||
|
dentry = d_alloc_parallel(dir, &nd->last, &wq);
|
||||||
if (IS_ERR(dentry))
|
if (IS_ERR(dentry))
|
||||||
return PTR_ERR(dentry);
|
return PTR_ERR(dentry);
|
||||||
|
}
|
||||||
|
if (d_in_lookup(dentry))
|
||||||
|
break;
|
||||||
|
|
||||||
if (!dentry) {
|
if (!(dentry->d_flags & DCACHE_OP_REVALIDATE))
|
||||||
dentry = d_alloc(dir, &nd->last);
|
break;
|
||||||
if (unlikely(!dentry))
|
|
||||||
return -ENOMEM;
|
error = d_revalidate(dentry, nd->flags);
|
||||||
need_lookup = true;
|
if (likely(error > 0))
|
||||||
} else if (dentry->d_inode) {
|
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 */
|
/* Cached positive dentry: will open in f_op->open */
|
||||||
goto out_no_open;
|
goto out_no_open;
|
||||||
}
|
}
|
||||||
|
@ -2968,9 +2982,10 @@ static int lookup_open(struct nameidata *nd, struct path *path,
|
||||||
}
|
}
|
||||||
|
|
||||||
no_open:
|
no_open:
|
||||||
if (need_lookup) {
|
if (d_in_lookup(dentry)) {
|
||||||
struct dentry *res = dir_inode->i_op->lookup(dir_inode, dentry,
|
struct dentry *res = dir_inode->i_op->lookup(dir_inode, dentry,
|
||||||
nd->flags);
|
nd->flags);
|
||||||
|
d_lookup_done(dentry);
|
||||||
if (unlikely(res)) {
|
if (unlikely(res)) {
|
||||||
if (IS_ERR(res)) {
|
if (IS_ERR(res)) {
|
||||||
error = PTR_ERR(res);
|
error = PTR_ERR(res);
|
||||||
|
|
Loading…
Reference in New Issue