Whamcloud - gitweb
lu_object: use hash_long() to hash fids.
authornikita <nikita>
Mon, 13 Nov 2006 14:14:29 +0000 (14:14 +0000)
committernikita <nikita>
Mon, 13 Nov 2006 14:14:29 +0000 (14:14 +0000)
lustre/obdclass/lu_object.c

index eff3744..01353a9 100644 (file)
@@ -37,6 +37,8 @@
 #include <linux/module.h>
 /* nr_free_pages() */
 #include <linux/swap.h>
+/* hash_long() */
+#include <linux/hash.h>
 #include <obd_support.h>
 #include <lustre_disk.h>
 #include <lustre_fid.h>
@@ -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,