Commit 504f3841 authored by Al Viro's avatar Al Viro Committed by Miklos Szeredi

ovl: ovl_obtain_alias(): don't call d_instantiate_anon() for old

The situation is the same as for __d_obtain_alias() (which is what that
thing is parallel to) - if we find a preexisting alias, we want to grab it,
drop the inode and return the alias we'd found.

The only thing d_instantiate_anon() does compared to that is spurious
security_d_instiate() that has already been done to that dentry with exact
same arguments.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent d80172c2
...@@ -308,9 +308,11 @@ static struct dentry *ovl_obtain_alias(struct super_block *sb, ...@@ -308,9 +308,11 @@ static struct dentry *ovl_obtain_alias(struct super_block *sb,
ovl_set_flag(OVL_UPPERDATA, inode); ovl_set_flag(OVL_UPPERDATA, inode);
dentry = d_find_any_alias(inode); dentry = d_find_any_alias(inode);
if (!dentry) { if (dentry)
goto out_iput;
dentry = d_alloc_anon(inode->i_sb); dentry = d_alloc_anon(inode->i_sb);
if (!dentry) if (unlikely(!dentry))
goto nomem; goto nomem;
oe = ovl_alloc_entry(lower ? 1 : 0); oe = ovl_alloc_entry(lower ? 1 : 0);
if (!oe) if (!oe)
...@@ -323,16 +325,18 @@ static struct dentry *ovl_obtain_alias(struct super_block *sb, ...@@ -323,16 +325,18 @@ static struct dentry *ovl_obtain_alias(struct super_block *sb,
dentry->d_fsdata = oe; dentry->d_fsdata = oe;
if (upper_alias) if (upper_alias)
ovl_dentry_set_upper_alias(dentry); ovl_dentry_set_upper_alias(dentry);
}
ovl_dentry_update_reval(dentry, upper, ovl_dentry_update_reval(dentry, upper,
DCACHE_OP_REVALIDATE | DCACHE_OP_WEAK_REVALIDATE); DCACHE_OP_REVALIDATE | DCACHE_OP_WEAK_REVALIDATE);
return d_instantiate_anon(dentry, inode); return d_instantiate_anon(dentry, inode);
nomem: nomem:
iput(inode);
dput(dentry); dput(dentry);
return ERR_PTR(-ENOMEM); dentry = ERR_PTR(-ENOMEM);
out_iput:
iput(inode);
return dentry;
} }
/* Get the upper or lower dentry in stach whose on layer @idx */ /* Get the upper or lower dentry in stach whose on layer @idx */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment