Commit ea936aeb authored by Al Viro's avatar Al Viro

massage __follow_mount_rcu() a bit

make the loop more similar to that in follow_managed(), with
explicit tracking of flags, etc.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent c108837e
...@@ -1269,12 +1269,6 @@ int follow_down_one(struct path *path) ...@@ -1269,12 +1269,6 @@ int follow_down_one(struct path *path)
} }
EXPORT_SYMBOL(follow_down_one); EXPORT_SYMBOL(follow_down_one);
static inline int managed_dentry_rcu(const struct path *path)
{
return (path->dentry->d_flags & DCACHE_MANAGE_TRANSIT) ?
path->dentry->d_op->d_manage(path, true) : 0;
}
/* /*
* Try to skip to top of mountpoint pile in rcuwalk mode. Fail if * Try to skip to top of mountpoint pile in rcuwalk mode. Fail if
* we meet a managed dentry that would need blocking. * we meet a managed dentry that would need blocking.
...@@ -1282,43 +1276,49 @@ static inline int managed_dentry_rcu(const struct path *path) ...@@ -1282,43 +1276,49 @@ static inline int managed_dentry_rcu(const struct path *path)
static bool __follow_mount_rcu(struct nameidata *nd, struct path *path, static bool __follow_mount_rcu(struct nameidata *nd, struct path *path,
struct inode **inode, unsigned *seqp) struct inode **inode, unsigned *seqp)
{ {
struct dentry *dentry = path->dentry;
unsigned int flags = dentry->d_flags;
if (likely(!(flags & DCACHE_MANAGED_DENTRY)))
return true;
if (unlikely(nd->flags & LOOKUP_NO_XDEV))
return false;
for (;;) { for (;;) {
struct mount *mounted;
/* /*
* Don't forget we might have a non-mountpoint managed dentry * Don't forget we might have a non-mountpoint managed dentry
* that wants to block transit. * that wants to block transit.
*/ */
switch (managed_dentry_rcu(path)) { if (unlikely(flags & DCACHE_MANAGE_TRANSIT)) {
case -ECHILD: int res = dentry->d_op->d_manage(path, true);
default: if (res)
return false; return res == -EISDIR;
case -EISDIR: flags = dentry->d_flags;
return true;
case 0:
break;
} }
if (!d_mountpoint(path->dentry)) if (flags & DCACHE_MOUNTED) {
return !(path->dentry->d_flags & DCACHE_NEED_AUTOMOUNT); struct mount *mounted = __lookup_mnt(path->mnt, dentry);
if (mounted) {
mounted = __lookup_mnt(path->mnt, path->dentry); path->mnt = &mounted->mnt;
if (!mounted) dentry = path->dentry = mounted->mnt.mnt_root;
break; nd->flags |= LOOKUP_JUMPED;
if (unlikely(nd->flags & LOOKUP_NO_XDEV)) *seqp = read_seqcount_begin(&dentry->d_seq);
return false; *inode = dentry->d_inode;
path->mnt = &mounted->mnt; /*
path->dentry = mounted->mnt.mnt_root; * We don't need to re-check ->d_seq after this
nd->flags |= LOOKUP_JUMPED; * ->d_inode read - there will be an RCU delay
*seqp = read_seqcount_begin(&path->dentry->d_seq); * between mount hash removal and ->mnt_root
/* * becoming unpinned.
* Update the inode too. We don't need to re-check the */
* dentry sequence number here after this d_inode read, flags = dentry->d_flags;
* because a mount-point is always pinned. continue;
*/ }
*inode = path->dentry->d_inode; if (read_seqretry(&mount_lock, nd->m_seq))
return false;
}
return !(flags & DCACHE_NEED_AUTOMOUNT);
} }
return !read_seqretry(&mount_lock, nd->m_seq) &&
!(path->dentry->d_flags & DCACHE_NEED_AUTOMOUNT);
} }
static inline int handle_mounts(struct nameidata *nd, struct dentry *dentry, static inline int handle_mounts(struct nameidata *nd, struct dentry *dentry,
......
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