Commit 7e08e9a8 authored by NeilBrown's avatar NeilBrown Committed by Greg Kroah-Hartman

staging: lustre: llite: simplify ll_find_alias()

Now that ll_find_alias is only searching for one type
of dentry, we can return as soon as we find it.
This allows substantial simplification, and brings the
bonus that we don't need to take the d_lock again just
to increment the ref-count.  We can increment it immediately
that the dentry is found.
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ac637746
...@@ -384,13 +384,11 @@ void ll_i2gids(__u32 *suppgids, struct inode *i1, struct inode *i2) ...@@ -384,13 +384,11 @@ void ll_i2gids(__u32 *suppgids, struct inode *i1, struct inode *i2)
*/ */
static struct dentry *ll_find_alias(struct inode *inode, struct dentry *dentry) static struct dentry *ll_find_alias(struct inode *inode, struct dentry *dentry)
{ {
struct dentry *alias, *invalid_alias; struct dentry *alias;
if (hlist_empty(&inode->i_dentry)) if (hlist_empty(&inode->i_dentry))
return NULL; return NULL;
invalid_alias = NULL;
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) { hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) {
LASSERT(alias != dentry); LASSERT(alias != dentry);
...@@ -400,22 +398,17 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *dentry) ...@@ -400,22 +398,17 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *dentry)
alias->d_name.hash == dentry->d_name.hash && alias->d_name.hash == dentry->d_name.hash &&
alias->d_name.len == dentry->d_name.len && alias->d_name.len == dentry->d_name.len &&
memcmp(alias->d_name.name, dentry->d_name.name, memcmp(alias->d_name.name, dentry->d_name.name,
dentry->d_name.len) == 0) dentry->d_name.len) == 0) {
invalid_alias = alias; dget_dlock(alias);
spin_unlock(&alias->d_lock); spin_unlock(&alias->d_lock);
spin_unlock(&inode->i_lock);
if (invalid_alias) return alias;
break;
} }
alias = invalid_alias ?: NULL;
if (alias) {
spin_lock(&alias->d_lock);
dget_dlock(alias);
spin_unlock(&alias->d_lock); spin_unlock(&alias->d_lock);
} }
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
return alias; return NULL;
} }
/* /*
......
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