From ebf04c3a3eeb6dd49756a93f31e0f90fd706a44f Mon Sep 17 00:00:00 2001 From: Benjamin Kaduk Date: Mon, 12 Jan 2015 16:13:28 -0500 Subject: [PATCH] Switch to jhash for VNODE_HASH 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 Tested-by: BuildBot --- src/vol/fssync-debug.c | 1 - src/vol/vnode.c | 48 ++++++++---------------------------------- src/vol/volume.c | 1 - src/vol/volume.h | 3 --- 4 files changed, 9 insertions(+), 44 deletions(-) diff --git a/src/vol/fssync-debug.c b/src/vol/fssync-debug.c index e51fcad03..47562dff1 100644 --- a/src/vol/fssync-debug.c +++ b/src/vol/fssync-debug.c @@ -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); diff --git a/src/vol/vnode.c b/src/vol/vnode.c index d9f8c1f54..ab1c349ad 100644 --- a/src/vol/vnode.c +++ b/src/vol/vnode.c @@ -30,6 +30,7 @@ #ifdef AFS_PTHREAD_ENV #include #endif +#include #include "rx/rx_queue.h" #include #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); - 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) diff --git a/src/vol/volume.c b/src/vol/volume.c index 49793a6c1..01595ecc4 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -8490,7 +8490,6 @@ AddVolumeToHashTable(Volume * vp, VolumeId hashid) head->len++; vp->hashid = hashid; queue_Append(head, vp); - vp->vnodeHashOffset = VolumeHashOffset_r(); } /** diff --git a/src/vol/volume.h b/src/vol/volume.h index 7762f237e..c0b74a6f5 100644 --- a/src/vol/volume.h +++ b/src/vol/volume.h @@ -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 -- 2.39.5