[PATCH 1/4] vfs - check non-mountpoint dentry might block in__follow_mount_rcu()

From: Ian Kent
Date: Tue Mar 01 2011 - 00:07:08 EST


When following a mount in rcu-walk mode we must check if the incoming dentry
is telling us it may need to block, even if it isn't actually a mountpoint.

Signed-off-by: Ian Kent <raven@xxxxxxxxxx>
---

fs/namei.c | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 0087cf9..a0f2179 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1022,6 +1022,14 @@ int follow_down_one(struct path *path)
return 0;
}

+static bool managed_dentry_might_block(struct dentry *dentry)
+{
+ if (dentry->d_flags & DCACHE_MANAGE_TRANSIT &&
+ dentry->d_op->d_manage(dentry, false, true) < 0)
+ return true;
+ return false;
+}
+
/*
* Skip to top of mountpoint pile in rcuwalk mode. We abort the rcu-walk if we
* meet a managed dentry and we're not walking to "..". True is returned to
@@ -1030,12 +1038,17 @@ int follow_down_one(struct path *path)
static bool __follow_mount_rcu(struct nameidata *nd, struct path *path,
struct inode **inode, bool reverse_transit)
{
+ /*
+ * Don't forgat we might have a non-mountpoint managed dentry
+ * that wants to block transit.
+ */
+ *inode = path->dentry->d_inode;
+ if (!reverse_transit &&
+ unlikely(managed_dentry_might_block(path->dentry)))
+ return false;
+
while (d_mountpoint(path->dentry)) {
struct vfsmount *mounted;
- if (unlikely(path->dentry->d_flags & DCACHE_MANAGE_TRANSIT) &&
- !reverse_transit &&
- path->dentry->d_op->d_manage(path->dentry, false, true) < 0)
- return false;
mounted = __lookup_mnt(path->mnt, path->dentry, 1);
if (!mounted)
break;
@@ -1043,6 +1056,9 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path,
path->dentry = mounted->mnt_root;
nd->seq = read_seqcount_begin(&path->dentry->d_seq);
*inode = path->dentry->d_inode;
+ if (!reverse_transit &&
+ unlikely(managed_dentry_might_block(path->dentry)))
+ return false;
}

if (unlikely(path->dentry->d_flags & DCACHE_NEED_AUTOMOUNT))

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/