From ca6a3e32f446e230b2546fcf71a518f7659cb2fb Mon Sep 17 00:00:00 2001 From: nikita Date: Tue, 21 Nov 2006 17:15:20 +0000 Subject: [PATCH] lu: ultimately hash function that works(tm)... famous last words. --- lustre/obdclass/lu_object.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 083fde3..8bf95aa 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -432,7 +432,8 @@ static __u32 fid_hash(const struct lu_fid *f, int bits) /* all objects with same id and different versions will belong to same * collisions list. */ #if 1 - return (fid_seq(f) - 1) * LUSTRE_SEQ_MAX_WIDTH + fid_oid(f); + return hash_long((fid_seq(f) - 1) * LUSTRE_SEQ_MAX_WIDTH + fid_oid(f), + bits); #else unsigned long hash; __u64 seq; @@ -441,7 +442,7 @@ static __u32 fid_hash(const struct lu_fid *f, int bits) hash = seq ^ fid_oid(f); if (sizeof hash != sizeof seq) hash ^= seq >> 32; - return hash_long(hash, bits); + return hash_long(hash, 32); #endif } @@ -471,11 +472,12 @@ struct lu_object *lu_object_find(const struct lu_env *env, * - return object. */ - bucket = s->ls_hash + (fid_hash(f, s->ls_hash_bits) & s->ls_hash_mask); + bucket = s->ls_hash + fid_hash(f, s->ls_hash_bits); + spin_lock(&s->ls_guard); o = htable_lookup(s, bucket, f); - spin_unlock(&s->ls_guard); + if (o != NULL) return o; -- 1.8.3.1