summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-06-10 07:51:30 -0700
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-07-16 07:22:13 +0200
commit0ec9bbce63581ce9e2b9bf0fd7ab5ba7e1d9b7a1 (patch)
tree4ccd0b872d48ebb9e9c5491142a1e92efc726331 /cpukit/libfs
parentmm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros (diff)
downloadrtems-0ec9bbce63581ce9e2b9bf0fd7ab5ba7e1d9b7a1.tar.bz2
vfs: make the string hashes salt the hash
We always mixed in the parent pointer into the dentry name hash, but we did it late at lookup time. It turns out that we can simplify that lookup-time action by salting the hash with the parent pointer early instead of late. A few other users of our string hashes also wanted to mix in their own pointers into the hash, and those are updated to use the same mechanism. Hash users that don't have any particular initial salt can just use the NULL pointer as a no-salt. Cc: Vegard Nossum <vegard.nossum@oracle.com> Cc: George Spelvin <linux@sciencehorizons.net> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'cpukit/libfs')
-rw-r--r--cpukit/libfs/src/jffs2/src/dir-rtems.c2
-rw-r--r--cpukit/libfs/src/jffs2/src/os-rtems.h3
-rw-r--r--cpukit/libfs/src/jffs2/src/readinode.c2
-rw-r--r--cpukit/libfs/src/jffs2/src/scan.c2
-rw-r--r--cpukit/libfs/src/jffs2/src/write.c4
5 files changed, 7 insertions, 6 deletions
diff --git a/cpukit/libfs/src/jffs2/src/dir-rtems.c b/cpukit/libfs/src/jffs2/src/dir-rtems.c
index 8d3c3bdc2c..9fa70bcec4 100644
--- a/cpukit/libfs/src/jffs2/src/dir-rtems.c
+++ b/cpukit/libfs/src/jffs2/src/dir-rtems.c
@@ -30,7 +30,7 @@ struct _inode *jffs2_lookup(struct _inode *dir_i, const unsigned char *name, siz
struct jffs2_inode_info *dir_f;
struct jffs2_full_dirent *fd = NULL, *fd_list;
uint32_t ino = 0;
- uint32_t hash = full_name_hash(name, namelen);
+ uint32_t hash = full_name_hash(NULL, name, namelen);
struct _inode *inode = NULL;
D1(printk("jffs2_lookup()\n"));
diff --git a/cpukit/libfs/src/jffs2/src/os-rtems.h b/cpukit/libfs/src/jffs2/src/os-rtems.h
index ab4f6d72bf..db1be61e67 100644
--- a/cpukit/libfs/src/jffs2/src/os-rtems.h
+++ b/cpukit/libfs/src/jffs2/src/os-rtems.h
@@ -41,9 +41,10 @@
struct _inode;
struct super_block;
-static inline unsigned int full_name_hash(const unsigned char * name, size_t len) {
+static inline unsigned int full_name_hash(const void *salt, const unsigned char * name, size_t len) {
uint32_t hash = 0;
+ (void)salt;
while (len--) {
hash = (hash << 4) | (hash >> 28);
hash ^= *(name++);
diff --git a/cpukit/libfs/src/jffs2/src/readinode.c b/cpukit/libfs/src/jffs2/src/readinode.c
index ba1ad6a22f..7a897b670d 100644
--- a/cpukit/libfs/src/jffs2/src/readinode.c
+++ b/cpukit/libfs/src/jffs2/src/readinode.c
@@ -683,7 +683,7 @@ static inline int read_direntry(struct jffs2_sb_info *c, struct jffs2_raw_node_r
}
}
- fd->nhash = full_name_hash(fd->name, rd->nsize);
+ fd->nhash = full_name_hash(NULL, fd->name, rd->nsize);
fd->next = NULL;
fd->name[rd->nsize] = '\0';
diff --git a/cpukit/libfs/src/jffs2/src/scan.c b/cpukit/libfs/src/jffs2/src/scan.c
index 10bf007819..177a0cdd3f 100644
--- a/cpukit/libfs/src/jffs2/src/scan.c
+++ b/cpukit/libfs/src/jffs2/src/scan.c
@@ -1103,7 +1103,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
fd->next = NULL;
fd->version = je32_to_cpu(rd->version);
fd->ino = je32_to_cpu(rd->ino);
- fd->nhash = full_name_hash(fd->name, checkedlen);
+ fd->nhash = full_name_hash(NULL, fd->name, checkedlen);
fd->type = rd->type;
jffs2_add_fd_to_list(c, fd, &ic->scan_dents);
diff --git a/cpukit/libfs/src/jffs2/src/write.c b/cpukit/libfs/src/jffs2/src/write.c
index ac3ec295d5..3d49ec05ca 100644
--- a/cpukit/libfs/src/jffs2/src/write.c
+++ b/cpukit/libfs/src/jffs2/src/write.c
@@ -247,7 +247,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
fd->version = je32_to_cpu(rd->version);
fd->ino = je32_to_cpu(rd->ino);
- fd->nhash = full_name_hash(name, namelen);
+ fd->nhash = full_name_hash(NULL, name, namelen);
fd->type = rd->type;
memcpy(fd->name, name, namelen);
fd->name[namelen]=0;
@@ -600,7 +600,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
jffs2_add_fd_to_list(c, fd, &dir_f->dents);
mutex_unlock(&dir_f->sem);
} else {
- uint32_t nhash = full_name_hash(name, namelen);
+ uint32_t nhash = full_name_hash(NULL, name, namelen);
fd = dir_f->dents;
/* We don't actually want to reserve any space, but we do