Commit fb66a1989c8abc3015aa334f617658b277e5fe98

Authored by Christoph Hellwig
Committed by Linus Torvalds
1 parent d7dd618a59

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: Christoph Hellwig <hch@lst.de>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 6 additions and 6 deletions Side-by-side Diff

... ... @@ -37,6 +37,9 @@
37 37 return get_name(dir, name, child);
38 38 }
39 39  
  40 +/*
  41 + * Check if the dentry or any of it's aliases is acceptable.
  42 + */
40 43 static struct dentry *
41 44 find_acceptable_alias(struct dentry *result,
42 45 int (*acceptable)(void *context, struct dentry *dentry),
... ... @@ -44,6 +47,9 @@
44 47 {
45 48 struct dentry *dentry, *toput = NULL;
46 49  
  50 + if (acceptable(context, result))
  51 + return result;
  52 +
47 53 spin_lock(&dcache_lock);
48 54 list_for_each_entry(dentry, &result->d_inode->i_dentry, d_alias) {
49 55 dget_locked(dentry);
... ... @@ -126,9 +132,6 @@
126 132  
127 133 target_dir = dget(result);
128 134 } else {
129   - if (acceptable(context, result))
130   - return result;
131   -
132 135 alias = find_acceptable_alias(result, acceptable, context);
133 136 if (alias)
134 137 return alias;
... ... @@ -289,9 +292,6 @@
289 292 }
290 293 }
291 294 dput(target_dir);
292   - /* now result is properly connected, it is our best bet */
293   - if (acceptable(context, result))
294   - return result;
295 295  
296 296 alias = find_acceptable_alias(result, acceptable, context);
297 297 if (alias)