Skip to content

Commit

Permalink
get rid of the last LOOKUP_RCU dependencies in link_path_walk()
Browse files Browse the repository at this point in the history
New helper: terminate_walk().  An error has happened during pathname
resolution and we either drop nd->path or terminate RCU, depending
the mode we had been in.  After that, nd is essentially empty.
Switch link_path_walk() to using that for cleanup.

Now the top-level logics in link_path_walk() is back to sanity.  RCU
dependencies are in the lower-level functions.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Mar 14, 2011
1 parent a7472ba commit 951361f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,18 @@ static inline int handle_dots(struct nameidata *nd, int type)
return 0;
}

static void terminate_walk(struct nameidata *nd)
{
if (!(nd->flags & LOOKUP_RCU)) {
path_put(&nd->path);
} else {
nd->flags &= ~LOOKUP_RCU;
nd->root.mnt = NULL;
rcu_read_unlock();
br_read_unlock(vfsmount_lock);
}
}

/*
* Name resolution.
* This is the basic name resolution function, turning a pathname into
Expand Down Expand Up @@ -1482,14 +1494,7 @@ static int link_path_walk(const char *name, struct nameidata *nd)
nd->last_type = type;
return 0;
}
if (!(nd->flags & LOOKUP_RCU))
path_put(&nd->path);
if (nd->flags & LOOKUP_RCU) {
nd->flags &= ~LOOKUP_RCU;
nd->root.mnt = NULL;
rcu_read_unlock();
br_read_unlock(vfsmount_lock);
}
terminate_walk(nd);
return err;
}

Expand Down

0 comments on commit 951361f

Please sign in to comment.