From: Andreas Dilger Date: Wed, 7 May 2014 05:42:15 +0000 (-0600) Subject: LU-4974 lod: use common hash function for OST pool X-Git-Tag: 2.6.51~81 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=ba951cd63ccdbab34b55ce466a6630fd0381a276;p=fs%2Flustre-release.git LU-4974 lod: use common hash function for OST pool Use the common djb2 hash function for OST pool lookup. This is used for string-based hashing in other parts of the code. It doesn't make sense to have a custom hash function just for OST pool lookup, since there aren't expected to be a huge number of pools and there is no expectation that one of these functions is better than the other. Signed-off-by: Andreas Dilger Change-Id: I501a42bc169243204dfc847c0388240fc2500c1e Reviewed-on: http://review.whamcloud.com/10243 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- diff --git a/lustre/lod/lod_pool.c b/lustre/lod/lod_pool.c index 6eaa6d7..1404073 100644 --- a/lustre/lod/lod_pool.c +++ b/lustre/lod/lod_pool.c @@ -132,11 +132,7 @@ static void pool_putref_locked(struct pool_desc *pool) /** * Hash the pool name for use by the cfs_hash handlers. * - * hash function using a Rotating Hash algorithm - * Knuth, D. The Art of Computer Programming, - * Volume 3: Sorting and Searching, - * Chapter 6.4. - * Addison Wesley, 1973 + * Use the standard DJB2 hash function for ASCII strings in Lustre. * * \param[in] hash_body hash structure where this key is embedded (unused) * \param[in] key key to be hashed (in this case the pool name) @@ -146,18 +142,7 @@ static void pool_putref_locked(struct pool_desc *pool) */ static __u32 pool_hashfn(cfs_hash_t *hash_body, const void *key, unsigned mask) { - int i; - __u32 result; - char *poolname; - - result = 0; - poolname = (char *)key; - for (i = 0; i < LOV_MAXPOOLNAME; i++) { - if (poolname[i] == '\0') - break; - result = (result << 4) ^ (result >> 28) ^ poolname[i]; - } - return result % mask; + return cfs_hash_djb2_hash(key, strnlen(key, LOV_MAXPOOLNAME), mask); } /**