[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YJb9KFBO7MwJeDHz@zeniv-ca.linux.org.uk>
Date: Sat, 8 May 2021 21:05:44 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Jia He <justin.he@....com>, Petr Mladek <pmladek@...e.com>,
Steven Rostedt <rostedt@...dmis.org>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Jonathan Corbet <corbet@....net>,
Al Viro <viro@....linux.org.uk>,
Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ibm.com>,
"Eric W . Biederman" <ebiederm@...ssion.com>,
"Darrick J. Wong" <darrick.wong@...cle.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Ira Weiny <ira.weiny@...el.com>,
Eric Biggers <ebiggers@...gle.com>,
"Ahmed S. Darwish" <a.darwish@...utronix.de>,
"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-s390 <linux-s390@...r.kernel.org>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>
Subject: Re: [PATCH RFC 1/3] fs: introduce helper d_path_fast()
On Sat, May 08, 2021 at 01:39:45PM -0700, Linus Torvalds wrote:
> +static inline int prepend_entries(struct prepend_buffer *b, const struct path *path, const struct path *root, struct mount *mnt)
If anything, s/path/dentry/, since vfsmnt here will be equal to &mnt->mnt all along.
> +{
> + struct dentry *dentry = path->dentry;
> + struct vfsmount *vfsmnt = path->mnt;
> +
> + while (dentry != root->dentry || vfsmnt != root->mnt) {
> + int error;
> + struct dentry * parent;
> +
> + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
> + struct mount *parent = READ_ONCE(mnt->mnt_parent);
> + struct mnt_namespace *mnt_ns;
> +
> + /* Escaped? */
> + if (dentry != vfsmnt->mnt_root)
> + return 3;
> +
> + /* Global root? */
> + if (mnt != parent) {
> + dentry = READ_ONCE(mnt->mnt_mountpoint);
> + mnt = parent;
> + vfsmnt = &mnt->mnt;
> + continue;
> + }
> + mnt_ns = READ_ONCE(mnt->mnt_ns);
> + /* open-coded is_mounted() to use local mnt_ns */
> + if (!IS_ERR_OR_NULL(mnt_ns) && !is_anon_ns(mnt_ns))
> + return 1; // absolute root
> +
> + return 2; // detached or not attached yet
> + break;
?
> + }
> + parent = dentry->d_parent;
> + prefetch(parent);
> + error = prepend_name(b, &dentry->d_name);
> + if (error)
> + break;
return error, surely?
> + dentry = parent;
> + }
> + return 0;
> +}
FWIW, if we go that way, I would make that
while (dentry != root->dentry || &mnt->mnt != root->mnt) {
int error;
struct dentry *parent = READ_ONCE(dentry->d_parent);
if (unlikely(dentry == mnt->mnt.mnt_root)) {
struct mount *m = READ_ONCE(mnt->mnt_parent);
/* Global root? */
if (unlikely(mnt == m) {
struct mnt_namespace *mnt_ns;
mnt_ns = READ_ONCE(mnt->mnt_ns);
/* open-coded is_mounted() to use local mnt_ns */
if (!IS_ERR_OR_NULL(mnt_ns) && !is_anon_ns(mnt_ns))
return 1; // absolute root
else
return 2; // detached or not attached yet
}
// cross into whatever it's mounted on
dentry = READ_ONCE(mnt->mnt_mountpoint);
mnt = m;
continue;
}
/* Escaped? */
if (unlikely(dentry == parent))
return 3;
prefetch(parent);
error = prepend_name(b, &dentry->d_name);
if (error)
return error;
dentry = parent;
}
return 0;
Powered by blists - more mailing lists