Commit d7dd618a5901ce0b44ef518208b35f728775db74

Authored by Christoph Hellwig
Committed by Linus Torvalds
1 parent 10f11c341d

knfsd: exportfs: untangle ISDIR logic in find_exported_dentry

Rework some logic in find_exported_dentry so that we only have a single
S_ISDIR check and logic that makes clear to the reader what we're really doing
here.

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 10 additions and 16 deletions Side-by-side Diff

... ... @@ -116,30 +116,23 @@
116 116 if (IS_ERR(result))
117 117 return result;
118 118  
119   - if (S_ISDIR(result->d_inode->i_mode) &&
120   - (result->d_flags & DCACHE_DISCONNECTED)) {
121   - /* it is an unconnected directory, we must connect it */
122   - ;
123   - } else {
124   - if (acceptable(context, result))
125   - return result;
126   - if (S_ISDIR(result->d_inode->i_mode)) {
  119 + if (S_ISDIR(result->d_inode->i_mode)) {
  120 + if (!(result->d_flags & DCACHE_DISCONNECTED)) {
  121 + if (acceptable(context, result))
  122 + return result;
127 123 err = -EACCES;
128 124 goto err_result;
129 125 }
130 126  
  127 + target_dir = dget(result);
  128 + } else {
  129 + if (acceptable(context, result))
  130 + return result;
  131 +
131 132 alias = find_acceptable_alias(result, acceptable, context);
132 133 if (alias)
133 134 return alias;
134   - }
135 135  
136   - /* It's a directory, or we are required to confirm the file's
137   - * location in the tree based on the parent information
138   - */
139   - dprintk("find_exported_dentry: need to look harder for %s/%d\n",sb->s_id,*(int*)obj);
140   - if (S_ISDIR(result->d_inode->i_mode))
141   - target_dir = dget(result);
142   - else {
143 136 if (parent == NULL)
144 137 goto err_result;
145 138  
... ... @@ -149,6 +142,7 @@
149 142 goto err_result;
150 143 }
151 144 }
  145 +
152 146 /*
153 147 * Now we need to make sure that target_dir is properly connected.
154 148 * It may already be, as the flag isn't always updated when connection