]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Switch to jhash for VNODE_HASH
authorBenjamin Kaduk <kaduk@mit.edu>
Mon, 12 Jan 2015 21:13:28 +0000 (16:13 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Sat, 22 Aug 2015 16:44:18 +0000 (12:44 -0400)
Remove the vnodeHashOffset field, as the Jenkins hash will get
a uniform-enough distribution without this extra help.  Per-volume
unique hashing is retained by using the volume ID as the initial
value input to the Jenkins hash.

While here, increase the vnode hash table size from 256 to 2048.

Change-Id: I353dfc8178f13f4e9adcd03a331adf2a7c64a1a9
Reviewed-on: http://gerrit.openafs.org/11666
Reviewed-by: Daria Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
src/vol/fssync-debug.c
src/vol/vnode.c
src/vol/volume.c
src/vol/volume.h

index e51fcad036fd6089a93f939b482e1818ef1c3de7..47562dff13999592e868e60e3049f865ef9bdb98 100644 (file)
@@ -706,7 +706,6 @@ VolQuery(struct cmd_syndesc * as, void * rock)
        printf("\tlinkHandle      = %p\n", v.linkHandle);
        printf("\tnextVnodeUnique = %u\n", v.nextVnodeUnique);
        printf("\tdiskDataHandle  = %p\n", v.diskDataHandle);
-       printf("\tvnodeHashOffset = %u\n", v.vnodeHashOffset);
        printf("\tshuttingDown    = %d\n", v.shuttingDown);
        printf("\tgoingOffline    = %d\n", v.goingOffline);
        printf("\tcacheCheck      = %u\n", v.cacheCheck);
index d9f8c1f542965ff9846549804c620e8b26ba731c..ab1c349adc820161d8cca5d4e9579fb0e68a112a 100644 (file)
@@ -30,6 +30,7 @@
 #ifdef AFS_PTHREAD_ENV
 #include <opr/lock.h>
 #endif
+#include <opr/jhash.h>
 #include "rx/rx_queue.h"
 #include <afs/afsint.h>
 #include "nfs.h"
@@ -83,49 +84,18 @@ VNLog(afs_int32 aop, afs_int32 anparms, ... )
 }
 
 
-
-
-/* Vnode hash table.  Find hash chain by taking lower bits of
- * (volume_hash_offset + vnode).
- * This distributes the root inodes of the volumes over the
- * hash table entries and also distributes the vnodes of
- * volumes reasonably fairly.  The volume_hash_offset field
- * for each volume is established as the volume comes on line
- * by using the VOLUME_HASH_OFFSET macro.  This distributes the
- * volumes fairly among the cache entries, both when servicing
- * a small number of volumes and when servicing a large number.
- */
-
-/* VolumeHashOffset -- returns a new value to be stored in the
- * volumeHashOffset of a Volume structure.  Called when a
- * volume is initialized.  Sets the volumeHashOffset so that
- * vnode cache entries are distributed reasonably between
- * volumes (the root vnodes of the volumes will hash to
- * different values, and spacing is maintained between volumes
- * when there are not many volumes represented), and spread
- * equally amongst vnodes within a single volume.
+/* Vnode hash table.  Just use the Jenkins hash of the vnode number,
+ * with the volume ID as an initval because it's there.  (That will
+ * make the same vnode number in different volumes hash to a different
+ * value, which would probably not even be a big deal anyway.)
  */
-int
-VolumeHashOffset_r(void)
-{
-    static int nextVolumeHashOffset = 0;
-    /* hashindex Must be power of two in size */
-#   define hashShift 3
-#   define hashMask ((1<<hashShift)-1)
-    static byte hashindex[1 << hashShift] =
-       { 0, 128, 64, 192, 32, 160, 96, 224 };
-    int offset;
-    offset = hashindex[nextVolumeHashOffset & hashMask]
-       + (nextVolumeHashOffset >> hashShift);
-    nextVolumeHashOffset++;
-    return offset;
-}
 
-/* Change hashindex (above) if you change this constant */
-#define VNODE_HASH_TABLE_SIZE 256
+#define VNODE_HASH_TABLE_BITS 11
+#define VNODE_HASH_TABLE_SIZE opr_jhash_size(VNODE_HASH_TABLE_BITS)
+#define VNODE_HASH_TABLE_MASK opr_jhash_mask(VNODE_HASH_TABLE_BITS)
 private Vnode *VnodeHashTable[VNODE_HASH_TABLE_SIZE];
 #define VNODE_HASH(volumeptr,vnodenumber)\
-    ((volumeptr->vnodeHashOffset + vnodenumber)&(VNODE_HASH_TABLE_SIZE-1))
+    (opr_jhash_int((vnodenumber), V_id((volumeptr))) & VNODE_HASH_TABLE_MASK)
 
 
 
index 49793a6c13c02957c61b2163040bd1cc18db3a1b..01595ecc49a448d009d7983a63203ad95d10f13c 100644 (file)
@@ -8490,7 +8490,6 @@ AddVolumeToHashTable(Volume * vp, VolumeId hashid)
     head->len++;
     vp->hashid = hashid;
     queue_Append(head, vp);
-    vp->vnodeHashOffset = VolumeHashOffset_r();
 }
 
 /**
index 7762f237ecac55767dc15ae1c6e60fca2a6d08ac..c0b74a6f52e99f6af66b63e66004416a405d93ec 100644 (file)
@@ -665,9 +665,6 @@ typedef struct Volume {
                                 * uniquifier should be rewritten with the
                                 * value nextVnodeVersion */
     IHandle_t *diskDataHandle; /* Unix inode holding general volume info */
-    bit16 vnodeHashOffset;     /* Computed by HashOffset function in vnode.h.
-                                * Assigned to the volume when initialized.
-                                * Added to vnode number for hash table index */
     byte shuttingDown;         /* This volume is going to be detached */
     byte goingOffline;         /* This volume is going offline */
     bit32 cacheCheck;          /* Online sequence number to be used to invalidate vnode cache entries