Commit fb66a198 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

knfsd: exportfs: move acceptable check into find_acceptable_alias

All callers of find_acceptable_alias check if the current dentry is acceptable
before looking for other acceptable aliases using find_acceptable_alias.  Move
the check into find_acceptable_alias to make the code a little more dense and
add a comment to find_acceptable_alias that documents its intent.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent d7dd618a
...@@ -37,6 +37,9 @@ static int exportfs_get_name(struct dentry *dir, char *name, ...@@ -37,6 +37,9 @@ static int exportfs_get_name(struct dentry *dir, char *name,
return get_name(dir, name, child); return get_name(dir, name, child);
} }
/*
* Check if the dentry or any of it's aliases is acceptable.
*/
static struct dentry * static struct dentry *
find_acceptable_alias(struct dentry *result, find_acceptable_alias(struct dentry *result,
int (*acceptable)(void *context, struct dentry *dentry), int (*acceptable)(void *context, struct dentry *dentry),
...@@ -44,6 +47,9 @@ find_acceptable_alias(struct dentry *result, ...@@ -44,6 +47,9 @@ find_acceptable_alias(struct dentry *result,
{ {
struct dentry *dentry, *toput = NULL; struct dentry *dentry, *toput = NULL;
if (acceptable(context, result))
return result;
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
list_for_each_entry(dentry, &result->d_inode->i_dentry, d_alias) { list_for_each_entry(dentry, &result->d_inode->i_dentry, d_alias) {
dget_locked(dentry); dget_locked(dentry);
...@@ -126,9 +132,6 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent, ...@@ -126,9 +132,6 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent,
target_dir = dget(result); target_dir = dget(result);
} else { } else {
if (acceptable(context, result))
return result;
alias = find_acceptable_alias(result, acceptable, context); alias = find_acceptable_alias(result, acceptable, context);
if (alias) if (alias)
return alias; return alias;
...@@ -289,9 +292,6 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent, ...@@ -289,9 +292,6 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent,
} }
} }
dput(target_dir); dput(target_dir);
/* now result is properly connected, it is our best bet */
if (acceptable(context, result))
return result;
alias = find_acceptable_alias(result, acceptable, context); alias = find_acceptable_alias(result, acceptable, context);
if (alias) if (alias)
......
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