Commit 5f833af7 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] namei.c: take vfsmount_lock

From: Mike Waychison <Michael.Waychison@Sun.COM>

The attached patch ensures that we grab vfsmount_lock when grabbing a
reference to mnt_parent in follow_up and follow_dotdot.

We also don't need to access ->mnt_parent in follow_mount and
__follow_down to mntput because we already the parent pointer on the stack.
parent 122eace8
......@@ -420,15 +420,15 @@ int follow_up(struct vfsmount **mnt, struct dentry **dentry)
{
struct vfsmount *parent;
struct dentry *mountpoint;
spin_lock(&dcache_lock);
spin_lock(&vfsmount_lock);
parent=(*mnt)->mnt_parent;
if (parent == *mnt) {
spin_unlock(&dcache_lock);
spin_unlock(&vfsmount_lock);
return 0;
}
mntget(parent);
mountpoint=dget((*mnt)->mnt_mountpoint);
spin_unlock(&dcache_lock);
spin_unlock(&vfsmount_lock);
dput(*dentry);
*dentry = mountpoint;
mntput(*mnt);
......@@ -446,9 +446,9 @@ static int follow_mount(struct vfsmount **mnt, struct dentry **dentry)
struct vfsmount *mounted = lookup_mnt(*mnt, *dentry);
if (!mounted)
break;
mntput(*mnt);
*mnt = mounted;
dput(*dentry);
mntput(mounted->mnt_parent);
*dentry = dget(mounted->mnt_root);
res = 1;
}
......@@ -464,9 +464,9 @@ static inline int __follow_down(struct vfsmount **mnt, struct dentry **dentry)
mounted = lookup_mnt(*mnt, *dentry);
if (mounted) {
mntput(*mnt);
*mnt = mounted;
dput(*dentry);
mntput(mounted->mnt_parent);
*dentry = dget(mounted->mnt_root);
return 1;
}
......@@ -498,14 +498,16 @@ static inline void follow_dotdot(struct vfsmount **mnt, struct dentry **dentry)
dput(old);
break;
}
spin_unlock(&dcache_lock);
spin_lock(&vfsmount_lock);
parent = (*mnt)->mnt_parent;
if (parent == *mnt) {
spin_unlock(&dcache_lock);
spin_unlock(&vfsmount_lock);
break;
}
mntget(parent);
*dentry = dget((*mnt)->mnt_mountpoint);
spin_unlock(&dcache_lock);
spin_unlock(&vfsmount_lock);
dput(old);
mntput(*mnt);
*mnt = parent;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment