Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 310054
b: refs/heads/master
c: 697f514
h: refs/heads/master
v: v3
  • Loading branch information
Miklos Szeredi authored and Al Viro committed Jun 1, 2012
1 parent fae7d78 commit 7e3054f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e41f941a23115e84a8550b3d901a13a14b2edc2f
refs/heads/master: 697f514df10b0f46bcd7596c1be18b7e2e9b28bb
59 changes: 45 additions & 14 deletions trunk/fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1125,8 +1125,8 @@ static struct dentry *__lookup_hash(struct qstr *name,
* small and for now I'd prefer to have fast path as straight as possible.
* It _is_ time-critical.
*/
static int do_lookup(struct nameidata *nd, struct qstr *name,
struct path *path, struct inode **inode)
static int lookup_fast(struct nameidata *nd, struct qstr *name,
struct path *path, struct inode **inode)
{
struct vfsmount *mnt = nd->path.mnt;
struct dentry *dentry, *parent = nd->path.dentry;
Expand Down Expand Up @@ -1208,7 +1208,7 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
goto need_lookup;
}
}
done:

path->mnt = mnt;
path->dentry = dentry;
err = follow_managed(path, nd->flags);
Expand All @@ -1222,14 +1222,34 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
return 0;

need_lookup:
return 1;
}

/* Fast lookup failed, do it the slow way */
static int lookup_slow(struct nameidata *nd, struct qstr *name,
struct path *path)
{
struct dentry *dentry, *parent;
int err;

parent = nd->path.dentry;
BUG_ON(nd->inode != parent->d_inode);

mutex_lock(&parent->d_inode->i_mutex);
dentry = __lookup_hash(name, parent, nd);
mutex_unlock(&parent->d_inode->i_mutex);
if (IS_ERR(dentry))
return PTR_ERR(dentry);
goto done;
path->mnt = nd->path.mnt;
path->dentry = dentry;
err = follow_managed(path, nd->flags);
if (unlikely(err < 0)) {
path_put_conditional(path, nd);
return err;
}
if (err)
nd->flags |= LOOKUP_JUMPED;
return 0;
}

static inline int may_lookup(struct nameidata *nd)
Expand Down Expand Up @@ -1301,21 +1321,26 @@ static inline int walk_component(struct nameidata *nd, struct path *path,
*/
if (unlikely(type != LAST_NORM))
return handle_dots(nd, type);
err = do_lookup(nd, name, path, &inode);
err = lookup_fast(nd, name, path, &inode);
if (unlikely(err)) {
terminate_walk(nd);
return err;
}
if (!inode) {
path_to_nameidata(path, nd);
terminate_walk(nd);
return -ENOENT;
if (err < 0)
goto out_err;

err = lookup_slow(nd, name, path);
if (err < 0)
goto out_err;

inode = path->dentry->d_inode;
}
err = -ENOENT;
if (!inode)
goto out_path_put;

if (should_follow_link(inode, follow)) {
if (nd->flags & LOOKUP_RCU) {
if (unlikely(unlazy_walk(nd, path->dentry))) {
terminate_walk(nd);
return -ECHILD;
err = -ECHILD;
goto out_err;
}
}
BUG_ON(inode != path->dentry->d_inode);
Expand All @@ -1324,6 +1349,12 @@ static inline int walk_component(struct nameidata *nd, struct path *path,
path_to_nameidata(path, nd);
nd->inode = inode;
return 0;

out_path_put:
path_to_nameidata(path, nd);
out_err:
terminate_walk(nd);
return err;
}

/*
Expand Down

0 comments on commit 7e3054f

Please sign in to comment.