Commit a1eb33153090549e622ab42cb375af06614dd7a8

Authored by Miklos Szeredi
Committed by Al Viro
1 parent e276ae672f

vfs: do_last(): inline walk_component()

Copy walk_component() into do_lookup().

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

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

... ... @@ -2200,6 +2200,7 @@
2200 2200 int want_write = 0;
2201 2201 int acc_mode = op->acc_mode;
2202 2202 struct file *filp;
  2203 + struct inode *inode;
2203 2204 int error;
2204 2205  
2205 2206 nd->flags &= ~LOOKUP_PARENT;
2206 2207  
... ... @@ -2237,12 +2238,36 @@
2237 2238 if (open_flag & O_PATH && !(nd->flags & LOOKUP_FOLLOW))
2238 2239 symlink_ok = 1;
2239 2240 /* we _can_ be in RCU mode here */
2240   - error = walk_component(nd, path, &nd->last, LAST_NORM,
2241   - !symlink_ok);
2242   - if (error < 0)
2243   - return ERR_PTR(error);
2244   - if (error) /* symlink */
  2241 + error = lookup_fast(nd, &nd->last, path, &inode);
  2242 + if (unlikely(error)) {
  2243 + if (error < 0)
  2244 + goto exit;
  2245 +
  2246 + error = lookup_slow(nd, &nd->last, path);
  2247 + if (error < 0)
  2248 + goto exit;
  2249 +
  2250 + inode = path->dentry->d_inode;
  2251 + }
  2252 + error = -ENOENT;
  2253 + if (!inode) {
  2254 + path_to_nameidata(path, nd);
  2255 + goto exit;
  2256 + }
  2257 +
  2258 + if (should_follow_link(inode, !symlink_ok)) {
  2259 + if (nd->flags & LOOKUP_RCU) {
  2260 + if (unlikely(unlazy_walk(nd, path->dentry))) {
  2261 + error = -ECHILD;
  2262 + goto exit;
  2263 + }
  2264 + }
  2265 + BUG_ON(inode != path->dentry->d_inode);
2245 2266 return NULL;
  2267 + }
  2268 + path_to_nameidata(path, nd);
  2269 + nd->inode = inode;
  2270 +
2246 2271 /* sayonara */
2247 2272 error = complete_walk(nd);
2248 2273 if (error)