From: NeilBrown <neil@brown.name>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
David Howells <dhowells@redhat.com>,
Chuck Lever <chuck.lever@oracle.com>,
Jeff Layton <jlayton@kernel.org>
Cc: linux-nfs@vger.kernel.org, netfs@lists.linux.dev,
linux-fsdevel@vger.kernel.org
Subject: [PATCH 8/8] VFS: change lookup_one_common and lookup_noperm_common to take a qstr
Date: Fri, 14 Mar 2025 11:34:14 +1100 [thread overview]
Message-ID: <20250314045655.603377-9-neil@brown.name> (raw)
In-Reply-To: <20250314045655.603377-1-neil@brown.name>
These function already take a qstr of course, but they also currently
take a name/len was well and fill in the qstr.
Now they take a qstr that is already filled in, which is what all the
callers have.
Signed-off-by: NeilBrown <neil@brown.name>
---
fs/namei.c | 44 +++++++++++++++++++-------------------------
1 file changed, 19 insertions(+), 25 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index f89ed09c0b0b..a47a3795f2c7 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2833,13 +2833,12 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
}
EXPORT_SYMBOL(vfs_path_lookup);
-static int lookup_noperm_common(const char *name, struct dentry *base,
- int len,
- struct qstr *this)
+static int lookup_noperm_common(struct qstr *qname, struct dentry *base)
{
- this->name = name;
- this->len = len;
- this->hash = full_name_hash(base, name, len);
+ const char *name = qname->name;
+ u32 len = qname->len;
+
+ qname->hash = full_name_hash(base, name, len);
if (!len)
return -EACCES;
@@ -2856,7 +2855,7 @@ static int lookup_noperm_common(const char *name, struct dentry *base,
* to use its own hash..
*/
if (base->d_flags & DCACHE_OP_HASH) {
- int err = base->d_op->d_hash(base, this);
+ int err = base->d_op->d_hash(base, qname);
if (err < 0)
return err;
}
@@ -2864,10 +2863,10 @@ static int lookup_noperm_common(const char *name, struct dentry *base,
}
static int lookup_one_common(struct mnt_idmap *idmap,
- const char *name, struct dentry *base, int len,
- struct qstr *this) {
+ struct qstr *qname, struct dentry *base)
+{
int err;
- err = lookup_noperm_common(name, base, len, this);
+ err = lookup_noperm_common(qname, base);
if (err < 0)
return err;
return inode_permission(idmap, base->d_inode, MAY_EXEC);
@@ -2888,16 +2887,14 @@ static int lookup_one_common(struct mnt_idmap *idmap,
*/
struct dentry *try_lookup_noperm(struct qstr *name, struct dentry *base)
{
- struct qstr this;
int err;
WARN_ON_ONCE(!inode_is_locked(base->d_inode));
- err = lookup_noperm_common(name->name, base, name->len, &this);
+ err = lookup_noperm_common(name, base);
if (err)
return ERR_PTR(err);
- name->hash = this.hash;
return lookup_dcache(name, base, 0);
}
EXPORT_SYMBOL(try_lookup_noperm);
@@ -2915,17 +2912,16 @@ EXPORT_SYMBOL(try_lookup_noperm);
struct dentry *lookup_noperm(struct qstr name, struct dentry *base)
{
struct dentry *dentry;
- struct qstr this;
int err;
WARN_ON_ONCE(!inode_is_locked(base->d_inode));
- err = lookup_noperm_common(name.name, base, name.len, &this);
+ err = lookup_noperm_common(&name, base);
if (err)
return ERR_PTR(err);
- dentry = lookup_dcache(&this, base, 0);
- return dentry ? dentry : __lookup_slow(&this, base, 0);
+ dentry = lookup_dcache(&name, base, 0);
+ return dentry ? dentry : __lookup_slow(&name, base, 0);
}
EXPORT_SYMBOL(lookup_noperm);
@@ -2943,17 +2939,16 @@ struct dentry *lookup_one(struct vfsmount *mnt, struct qstr name,
struct dentry *base)
{
struct dentry *dentry;
- struct qstr this;
int err;
WARN_ON_ONCE(!inode_is_locked(base->d_inode));
- err = lookup_one_common(mnt_idmap(mnt), name.name, base, name.len, &this);
+ err = lookup_one_common(mnt_idmap(mnt), &name, base);
if (err)
return ERR_PTR(err);
- dentry = lookup_dcache(&this, base, 0);
- return dentry ? dentry : __lookup_slow(&this, base, 0);
+ dentry = lookup_dcache(&name, base, 0);
+ return dentry ? dentry : __lookup_slow(&name, base, 0);
}
EXPORT_SYMBOL(lookup_one);
@@ -2971,17 +2966,16 @@ EXPORT_SYMBOL(lookup_one);
struct dentry *lookup_one_unlocked(struct vfsmount *mnt,
struct qstr name, struct dentry *base)
{
- struct qstr this;
int err;
struct dentry *ret;
- err = lookup_one_common(mnt_idmap(mnt), name.name, base, name.len, &this);
+ err = lookup_one_common(mnt_idmap(mnt), &name, base);
if (err)
return ERR_PTR(err);
- ret = lookup_dcache(&this, base, 0);
+ ret = lookup_dcache(&name, base, 0);
if (!ret)
- ret = lookup_slow(&this, base, 0);
+ ret = lookup_slow(&name, base, 0);
return ret;
}
EXPORT_SYMBOL(lookup_one_unlocked);
--
2.48.1
next prev parent reply other threads:[~2025-03-14 4:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 0:34 [PATCH 0/8 RFC] tidy up various VFS lookup functions NeilBrown
2025-03-14 0:34 ` [PATCH 1/8] VFS: improve interface for lookup_one functions NeilBrown
2025-03-14 0:34 ` [PATCH 2/8] nfsd: Use lookup_one() rather than lookup_one_len() NeilBrown
2025-03-14 0:34 ` [PATCH 3/8] nfsd: use correct idmap for all accesses NeilBrown
2025-03-14 0:34 ` [PATCH 4/8] cachefiles: Use lookup_one() rather than lookup_one_len() NeilBrown
2025-03-14 0:34 ` [PATCH 5/8] cachefiles: use correct mnt_idmap NeilBrown
2025-03-14 0:34 ` [PATCH 6/8] VFS: rename lookup_one_len() family to lookup_noperm() and remove permission check NeilBrown
2025-03-14 0:34 ` [PATCH 7/8] Use try_lookup_noperm() instead of d_hash_and_lookup() outside of VFS NeilBrown
2025-03-14 0:34 ` NeilBrown [this message]
2025-03-14 10:38 ` [PATCH 0/8 RFC] tidy up various VFS lookup functions Christian Brauner
2025-03-17 2:06 ` NeilBrown
2025-03-18 13:57 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250314045655.603377-9-neil@brown.name \
--to=neil@brown.name \
--cc=brauner@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=dhowells@redhat.com \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=netfs@lists.linux.dev \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).