Commit 0145acc2 authored by Linus Torvalds's avatar Linus Torvalds

vfs: uninline full_name_hash()

.. and also use it in lookup_one_len() rather than open-coding it.

There aren't any performance-critical users, so inlining it is silly.
But it wouldn't matter if it wasn't for the fact that the word-at-a-time
dentry name patches want to conditionally replace the function, and
uninlining it sets the stage for that.

So again, this is a preparatory patch that doesn't change any semantics,
and only prepares for a much cleaner and testable word-at-a-time dentry
name accessor patch.
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8966be90
...@@ -1374,6 +1374,14 @@ static inline int can_lookup(struct inode *inode) ...@@ -1374,6 +1374,14 @@ static inline int can_lookup(struct inode *inode)
return 1; return 1;
} }
unsigned int full_name_hash(const unsigned char *name, unsigned int len)
{
unsigned long hash = init_name_hash();
while (len--)
hash = partial_name_hash(*name++, hash);
return end_name_hash(hash);
}
/* /*
* Name resolution. * Name resolution.
* This is the basic name resolution function, turning a pathname into * This is the basic name resolution function, turning a pathname into
...@@ -1775,24 +1783,21 @@ static struct dentry *lookup_hash(struct nameidata *nd) ...@@ -1775,24 +1783,21 @@ static struct dentry *lookup_hash(struct nameidata *nd)
struct dentry *lookup_one_len(const char *name, struct dentry *base, int len) struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
{ {
struct qstr this; struct qstr this;
unsigned long hash;
unsigned int c; unsigned int c;
WARN_ON_ONCE(!mutex_is_locked(&base->d_inode->i_mutex)); WARN_ON_ONCE(!mutex_is_locked(&base->d_inode->i_mutex));
this.name = name; this.name = name;
this.len = len; this.len = len;
this.hash = full_name_hash(name, len);
if (!len) if (!len)
return ERR_PTR(-EACCES); return ERR_PTR(-EACCES);
hash = init_name_hash();
while (len--) { while (len--) {
c = *(const unsigned char *)name++; c = *(const unsigned char *)name++;
if (c == '/' || c == '\0') if (c == '/' || c == '\0')
return ERR_PTR(-EACCES); return ERR_PTR(-EACCES);
hash = partial_name_hash(c, hash);
} }
this.hash = end_name_hash(hash);
/* /*
* See if the low-level filesystem might want * See if the low-level filesystem might want
* to use its own hash.. * to use its own hash..
......
...@@ -89,14 +89,7 @@ static inline unsigned long end_name_hash(unsigned long hash) ...@@ -89,14 +89,7 @@ static inline unsigned long end_name_hash(unsigned long hash)
} }
/* Compute the hash for a name string. */ /* Compute the hash for a name string. */
static inline unsigned int extern unsigned int full_name_hash(const unsigned char *, unsigned int);
full_name_hash(const unsigned char *name, unsigned int len)
{
unsigned long hash = init_name_hash();
while (len--)
hash = partial_name_hash(*name++, hash);
return end_name_hash(hash);
}
/* /*
* Try to keep struct dentry aligned on 64 byte cachelines (this will * Try to keep struct dentry aligned on 64 byte cachelines (this will
......
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