Changeset 0ec9bbc in rtems


Ignore:
Timestamp:
Jun 10, 2016, 2:51:30 PM (3 years ago)
Author:
Linus Torvalds <torvalds@…>
Branches:
master
Children:
976af92
Parents:
fb5bc64d
git-author:
Linus Torvalds <torvalds@…> (06/10/16 14:51:30)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/16/18 05:22:13)
Message:

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@…>
Cc: George Spelvin <linux@…>
Cc: Al Viro <viro@…>
Signed-off-by: Linus Torvalds <torvalds@…>

Location:
cpukit/libfs/src/jffs2/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/src/jffs2/src/dir-rtems.c

    rfb5bc64d r0ec9bbc  
    3131        struct jffs2_full_dirent *fd = NULL, *fd_list;
    3232        uint32_t ino = 0;
    33         uint32_t hash = full_name_hash(name, namelen);
     33        uint32_t hash = full_name_hash(NULL, name, namelen);
    3434        struct _inode *inode = NULL;
    3535
  • cpukit/libfs/src/jffs2/src/os-rtems.h

    rfb5bc64d r0ec9bbc  
    4242struct super_block;
    4343
    44 static inline unsigned int full_name_hash(const unsigned char * name, size_t len) {
     44static inline unsigned int full_name_hash(const void *salt, const unsigned char * name, size_t len) {
    4545
    4646        uint32_t hash = 0;
     47        (void)salt;
    4748        while (len--) {
    4849                hash = (hash << 4) | (hash >> 28);
  • cpukit/libfs/src/jffs2/src/readinode.c

    rfb5bc64d r0ec9bbc  
    684684        }
    685685
    686         fd->nhash = full_name_hash(fd->name, rd->nsize);
     686        fd->nhash = full_name_hash(NULL, fd->name, rd->nsize);
    687687        fd->next = NULL;
    688688        fd->name[rd->nsize] = '\0';
  • cpukit/libfs/src/jffs2/src/scan.c

    rfb5bc64d r0ec9bbc  
    11041104        fd->version = je32_to_cpu(rd->version);
    11051105        fd->ino = je32_to_cpu(rd->ino);
    1106         fd->nhash = full_name_hash(fd->name, checkedlen);
     1106        fd->nhash = full_name_hash(NULL, fd->name, checkedlen);
    11071107        fd->type = rd->type;
    11081108        jffs2_add_fd_to_list(c, fd, &ic->scan_dents);
  • cpukit/libfs/src/jffs2/src/write.c

    rfb5bc64d r0ec9bbc  
    248248        fd->version = je32_to_cpu(rd->version);
    249249        fd->ino = je32_to_cpu(rd->ino);
    250         fd->nhash = full_name_hash(name, namelen);
     250        fd->nhash = full_name_hash(NULL, name, namelen);
    251251        fd->type = rd->type;
    252252        memcpy(fd->name, name, namelen);
     
    601601                mutex_unlock(&dir_f->sem);
    602602        } else {
    603                 uint32_t nhash = full_name_hash(name, namelen);
     603                uint32_t nhash = full_name_hash(NULL, name, namelen);
    604604
    605605                fd = dir_f->dents;
Note: See TracChangeset for help on using the changeset viewer.