From 716d312a480c382b138a5040482fb190a68d13d7 Mon Sep 17 00:00:00 2001 From: nikita Date: Mon, 13 Nov 2006 14:14:29 +0000 Subject: [PATCH] lu_object: use hash_long() to hash fids. --- lustre/obdclass/lu_object.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index eff3744..01353a9 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -37,6 +37,8 @@ #include /* nr_free_pages() */ #include +/* hash_long() */ +#include #include #include #include @@ -424,11 +426,26 @@ static struct lu_object *htable_lookup(struct lu_site *s, return NULL; } +/* + * Hash-table parameters. Initialized in lu_global_init(). This assumes single + * site per node. + */ +static int lu_site_htable_bits; +static int lu_site_htable_size; +static int lu_site_htable_mask; + static __u32 fid_hash(const struct lu_fid *f) { + unsigned long hash; + __u64 seq; + /* all objects with same id and different versions will belong to same * collisions list. */ - return (fid_seq(f) - 1) * LUSTRE_SEQ_MAX_WIDTH + fid_oid(f); + seq = fid_seq(f); + hash = seq ^ fid_oid(f); + if (sizeof hash != sizeof seq) + hash ^= seq >> 32; + return hash_long(hash, lu_site_htable_bits); } /* @@ -505,14 +522,6 @@ static DECLARE_MUTEX(lu_sites_guard); static struct lu_env lu_shrink_env; /* - * Hash-table parameters. Initialized in lu_global_init(). This assumes single - * site per node. - */ -static int lu_site_htable_bits; -static int lu_site_htable_size; -static int lu_site_htable_mask; - -/* * Print all objects in @s. */ void lu_site_print(const struct lu_env *env, struct lu_site *s, void *cookie, -- 1.8.3.1