Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 312981
b: refs/heads/master
c: 32a7991
h: refs/heads/master
i:
  312979: 15d49aa
v: v3
  • Loading branch information
Al Viro committed Jul 22, 2012
1 parent 2839dfa commit 585d370
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 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: 3c0a6163688b8ca3f44029c7bdb3d91a865c878a
refs/heads/master: 32a7991b6a9c758e4e2b8166c5e1cc7563c3dcde
39 changes: 21 additions & 18 deletions trunk/fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,18 @@ EXPORT_SYMBOL(path_put);
* to restart the path walk from the beginning in ref-walk mode.
*/

static inline void lock_rcu_walk(void)
{
br_read_lock(&vfsmount_lock);
rcu_read_lock();
}

static inline void unlock_rcu_walk(void)
{
rcu_read_unlock();
br_read_unlock(&vfsmount_lock);
}

/**
* unlazy_walk - try to switch to ref-walk mode.
* @nd: nameidata pathwalk data
Expand Down Expand Up @@ -480,8 +492,7 @@ static int unlazy_walk(struct nameidata *nd, struct dentry *dentry)
}
mntget(nd->path.mnt);

rcu_read_unlock();
br_read_unlock(&vfsmount_lock);
unlock_rcu_walk();
nd->flags &= ~LOOKUP_RCU;
return 0;

Expand Down Expand Up @@ -522,15 +533,13 @@ static int complete_walk(struct nameidata *nd)
spin_lock(&dentry->d_lock);
if (unlikely(!__d_rcu_to_refcount(dentry, nd->seq))) {
spin_unlock(&dentry->d_lock);
rcu_read_unlock();
br_read_unlock(&vfsmount_lock);
unlock_rcu_walk();
return -ECHILD;
}
BUG_ON(nd->inode != dentry->d_inode);
spin_unlock(&dentry->d_lock);
mntget(nd->path.mnt);
rcu_read_unlock();
br_read_unlock(&vfsmount_lock);
unlock_rcu_walk();
}

if (likely(!(nd->flags & LOOKUP_JUMPED)))
Expand Down Expand Up @@ -985,8 +994,7 @@ static int follow_dotdot_rcu(struct nameidata *nd)
nd->flags &= ~LOOKUP_RCU;
if (!(nd->flags & LOOKUP_ROOT))
nd->root.mnt = NULL;
rcu_read_unlock();
br_read_unlock(&vfsmount_lock);
unlock_rcu_walk();
return -ECHILD;
}

Expand Down Expand Up @@ -1323,8 +1331,7 @@ static void terminate_walk(struct nameidata *nd)
nd->flags &= ~LOOKUP_RCU;
if (!(nd->flags & LOOKUP_ROOT))
nd->root.mnt = NULL;
rcu_read_unlock();
br_read_unlock(&vfsmount_lock);
unlock_rcu_walk();
}
}

Expand Down Expand Up @@ -1691,8 +1698,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
nd->path = nd->root;
nd->inode = inode;
if (flags & LOOKUP_RCU) {
br_read_lock(&vfsmount_lock);
rcu_read_lock();
lock_rcu_walk();
nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq);
} else {
path_get(&nd->path);
Expand All @@ -1704,8 +1710,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,

if (*name=='/') {
if (flags & LOOKUP_RCU) {
br_read_lock(&vfsmount_lock);
rcu_read_lock();
lock_rcu_walk();
set_root_rcu(nd);
} else {
set_root(nd);
Expand All @@ -1717,8 +1722,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
struct fs_struct *fs = current->fs;
unsigned seq;

br_read_lock(&vfsmount_lock);
rcu_read_lock();
lock_rcu_walk();

do {
seq = read_seqcount_begin(&fs->seq);
Expand Down Expand Up @@ -1753,8 +1757,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
if (fput_needed)
*fp = file;
nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq);
br_read_lock(&vfsmount_lock);
rcu_read_lock();
lock_rcu_walk();
} else {
path_get(&file->f_path);
fput_light(file, fput_needed);
Expand Down

0 comments on commit 585d370

Please sign in to comment.