ceph: make CRUSH hash function a bucket property

Make the integer hash function a property of the bucket it is used on.  This
allows us to gracefully add support for new hash functions without starting
from scatch.

Signed-off-by: Sage Weil <sage@newdream.net>
diff --git a/fs/ceph/crush/mapper.c b/fs/ceph/crush/mapper.c
index 54f3f40..2523d44 100644
--- a/fs/ceph/crush/mapper.c
+++ b/fs/ceph/crush/mapper.c
@@ -78,7 +78,7 @@
 
 		/* optimize common r=0 case */
 		if (pr == 0) {
-			s = crush_hash32_3(x, bucket->id, 0) %
+			s = crush_hash32_3(bucket->hash, x, bucket->id, 0) %
 				bucket->size;
 			bucket->perm[0] = s;
 			bucket->perm_n = 0xffff;   /* magic value, see below */
@@ -103,7 +103,7 @@
 		unsigned p = bucket->perm_n;
 		/* no point in swapping the final entry */
 		if (p < bucket->size - 1) {
-			i = crush_hash32_3(x, bucket->id, p) %
+			i = crush_hash32_3(bucket->hash, x, bucket->id, p) %
 				(bucket->size - p);
 			if (i) {
 				unsigned t = bucket->perm[p + i];
@@ -138,8 +138,8 @@
 	int i;
 
 	for (i = bucket->h.size-1; i >= 0; i--) {
-		__u64 w = crush_hash32_4(x, bucket->h.items[i], r,
-					 bucket->h.id);
+		__u64 w = crush_hash32_4(bucket->h.hash,x, bucket->h.items[i],
+					 r, bucket->h.id);
 		w &= 0xffff;
 		dprintk("list_choose i=%d x=%d r=%d item %d weight %x "
 			"sw %x rand %llx",
@@ -198,7 +198,8 @@
 	while (!terminal(n)) {
 		/* pick point in [0, w) */
 		w = bucket->node_weights[n];
-		t = (__u64)crush_hash32_4(x, n, r, bucket->h.id) * (__u64)w;
+		t = (__u64)crush_hash32_4(bucket->h.hash, x, n, r,
+					  bucket->h.id) * (__u64)w;
 		t = t >> 32;
 
 		/* descend to the left or right? */
@@ -224,7 +225,7 @@
 	__u64 draw;
 
 	for (i = 0; i < bucket->h.size; i++) {
-		draw = crush_hash32_3(x, bucket->h.items[i], r);
+		draw = crush_hash32_3(bucket->h.hash, x, bucket->h.items[i], r);
 		draw &= 0xffff;
 		draw *= bucket->straws[i];
 		if (i == 0 || draw > high_draw) {
@@ -267,7 +268,8 @@
 		return 0;
 	if (weight[item] == 0)
 		return 1;
-	if ((crush_hash32_2(x, item) & 0xffff) < weight[item])
+	if ((crush_hash32_2(CRUSH_HASH_RJENKINS1, x, item) & 0xffff)
+	    < weight[item])
 		return 0;
 	return 1;
 }