struct cfs_hash_ops {
/** return hashed value from @key */
- unsigned (*hs_hash)(struct cfs_hash *hs, const void *key, unsigned mask);
+ unsigned int (*hs_hash)(struct cfs_hash *hs, const void *key,
+ const unsigned int bits);
/** return key address of @hnode */
void * (*hs_key)(struct hlist_node *hnode);
/** copy key from @hnode to @key */
hs->hs_extra_bytes;
}
-static inline unsigned
-cfs_hash_id(struct cfs_hash *hs, const void *key, unsigned mask)
+static inline unsigned int
+cfs_hash_id(struct cfs_hash *hs, const void *key, const unsigned int bits)
{
- return hs->hs_ops->hs_hash(hs, key, mask);
+ return hs->hs_ops->hs_hash(hs, key, bits);
}
static inline void *
* Generic djb2 hash algorithm for character arrays.
*/
static inline unsigned
-cfs_hash_djb2_hash(const void *key, size_t size, unsigned mask)
+cfs_hash_djb2_hash(const void *key, size_t size, const unsigned int bits)
{
- unsigned i, hash = 5381;
+ unsigned int i, hash = 5381;
- LASSERT(key != NULL);
+ LASSERT(key != NULL);
- for (i = 0; i < size; i++)
- hash = hash * 33 + ((char *)key)[i];
+ for (i = 0; i < size; i++)
+ hash = hash * 33 + ((char *)key)[i];
- return (hash & mask);
+ return (hash & ((1U << bits) - 1));
}
/** iterate over all buckets in @bds (array of struct cfs_hash_bd) */
cfs_hash_bd_from_key(struct cfs_hash *hs, struct cfs_hash_bucket **bkts,
unsigned int bits, const void *key, struct cfs_hash_bd *bd)
{
- unsigned int index = cfs_hash_id(hs, key, (1U << bits) - 1);
+ unsigned int index = cfs_hash_id(hs, key, bits);
- LASSERT(bits == hs->hs_cur_bits || bits == hs->hs_rehash_bits);
+ LASSERT(bits == hs->hs_cur_bits || bits == hs->hs_rehash_bits);
- bd->bd_bucket = bkts[index & ((1U << (bits - hs->hs_bkt_bits)) - 1)];
- bd->bd_offset = index >> (bits - hs->hs_bkt_bits);
+ bd->bd_bucket = bkts[index & ((1U << (bits - hs->hs_bkt_bits)) - 1)];
+ bd->bd_offset = index >> (bits - hs->hs_bkt_bits);
}
void
/*
* Export handle<->flock hash operations.
*/
-static unsigned
-ldlm_export_flock_hash(struct cfs_hash *hs, const void *key, unsigned mask)
+static unsigned int
+ldlm_export_flock_hash(struct cfs_hash *hs, const void *key,
+ const unsigned int bits)
{
- return cfs_hash_64(*(__u64 *)key, 0) & mask;
+ return cfs_hash_64(*(__u64 *)key, bits);
}
static void *
* Export handle<->lock hash operations.
*/
static unsigned
-ldlm_export_lock_hash(struct cfs_hash *hs, const void *key, unsigned int mask)
+ldlm_export_lock_hash(struct cfs_hash *hs, const void *key,
+ const unsigned int bits)
{
- return cfs_hash_64(((struct lustre_handle *)key)->cookie, 0) & mask;
+ return cfs_hash_64(((struct lustre_handle *)key)->cookie, bits);
}
static void *
}
static unsigned int
-cdt_agent_record_hash(struct cfs_hash *hs, const void *key, unsigned int mask)
+cdt_agent_record_hash(struct cfs_hash *hs, const void *key,
+ const unsigned int bits)
{
- return cfs_hash_djb2_hash(key, sizeof(u64), mask);
+ return cfs_hash_djb2_hash(key, sizeof(u64), bits);
}
static void *cdt_agent_record_object(struct hlist_node *hnode)
#include "mdt_internal.h"
static unsigned int
-cdt_request_cookie_hash(struct cfs_hash *hs, const void *key, unsigned int mask)
+cdt_request_cookie_hash(struct cfs_hash *hs, const void *key,
+ const unsigned int bits)
{
- return cfs_hash_djb2_hash(key, sizeof(u64), mask);
+ return cfs_hash_djb2_hash(key, sizeof(u64), bits);
}
static void *cdt_request_cookie_object(struct hlist_node *hnode)
/*
* Hash operations for pid<->jobid
*/
-static unsigned jobid_hashfn(struct cfs_hash *hs, const void *key,
- unsigned mask)
+static unsigned int
+jobid_hashfn(struct cfs_hash *hs, const void *key, const unsigned int bits)
{
- return cfs_hash_djb2_hash(key, sizeof(pid_t), mask);
+ return cfs_hash_djb2_hash(key, sizeof(pid_t), bits);
}
static void *jobid_key(struct hlist_node *hnode)
struct rcu_head js_rcu; /* RCU head for job_reclaim_rcu*/
};
-static unsigned
-job_stat_hash(struct cfs_hash *hs, const void *key, unsigned mask)
+static unsigned int
+job_stat_hash(struct cfs_hash *hs, const void *key, const unsigned int bits)
{
- return cfs_hash_djb2_hash(key, strlen(key), mask);
+ return cfs_hash_djb2_hash(key, strlen(key), bits);
}
static void *job_stat_key(struct hlist_node *hnode)
/*
* nid<->nidstats hash operations
*/
-static unsigned
-nidstats_hash(struct cfs_hash *hs, const void *key, unsigned int mask)
+static unsigned int
+nidstats_hash(struct cfs_hash *hs, const void *key, const unsigned int bits)
{
- return cfs_hash_djb2_hash(key, sizeof(struct lnet_nid), mask);
+ return cfs_hash_djb2_hash(key, sizeof(struct lnet_nid), bits);
}
static void *
* client_generation<->export hash operations
*/
-static unsigned
-gen_hash(struct cfs_hash *hs, const void *key, unsigned mask)
+static unsigned int
+gen_hash(struct cfs_hash *hs, const void *key, const unsigned int bits)
{
- return cfs_hash_djb2_hash(key, sizeof(__u32), mask);
+ /* XXX did hash needs ? */
+ return cfs_hash_djb2_hash(key, sizeof(__u32), bits);
}
static void *
}
EXPORT_SYMBOL(nodemap_putref);
-static __u32 nodemap_hashfn(struct cfs_hash *hash_body,
- const void *key, unsigned mask)
+static unsigned int
+nodemap_hashfn(struct cfs_hash *hash_body,
+ const void *key, const unsigned int bits)
{
- return cfs_hash_djb2_hash(key, strlen(key), mask);
+ return cfs_hash_djb2_hash(key, strlen(key), bits);
}
static void *nodemap_hs_key(struct hlist_node *hnode)
.hop_compare = tbf_cli_compare,
};
-static unsigned nrs_tbf_jobid_hop_hash(struct cfs_hash *hs, const void *key,
- unsigned mask)
+static unsigned int
+nrs_tbf_jobid_hop_hash(struct cfs_hash *hs, const void *key,
+ const unsigned int bits)
{
- return cfs_hash_djb2_hash(key, strlen(key), mask);
+ return cfs_hash_djb2_hash(key, strlen(key), bits);
}
static int nrs_tbf_jobid_hop_keycmp(const void *key, struct hlist_node *hnode)
#define NRS_TBF_NID_BKT_BITS 8
#define NRS_TBF_NID_BITS 16
-static unsigned nrs_tbf_nid_hop_hash(struct cfs_hash *hs, const void *key,
- unsigned mask)
+static unsigned int
+nrs_tbf_nid_hop_hash(struct cfs_hash *hs, const void *key,
+ const unsigned int bits)
{
- return cfs_hash_djb2_hash(key, sizeof(lnet_nid_t), mask);
+ return cfs_hash_djb2_hash(key, sizeof(lnet_nid_t), bits);
}
static int nrs_tbf_nid_hop_keycmp(const void *key, struct hlist_node *hnode)
.o_rule_fini = nrs_tbf_nid_rule_fini,
};
-static unsigned nrs_tbf_hop_hash(struct cfs_hash *hs, const void *key,
- unsigned mask)
+static unsigned int
+nrs_tbf_hop_hash(struct cfs_hash *hs, const void *key,
+ const unsigned int bits)
{
- return cfs_hash_djb2_hash(key, strlen(key), mask);
+ return cfs_hash_djb2_hash(key, strlen(key), bits);
}
static int nrs_tbf_hop_keycmp(const void *key, struct hlist_node *hnode)
OBD_FREE(rule->tr_opcodes_str, strlen(rule->tr_opcodes_str) + 1);
}
-static unsigned nrs_tbf_opcode_hop_hash(struct cfs_hash *hs, const void *key,
- unsigned mask)
+static unsigned int
+nrs_tbf_opcode_hop_hash(struct cfs_hash *hs, const void *key,
+ const unsigned int bits)
{
- return cfs_hash_djb2_hash(key, sizeof(__u32), mask);
+ /* XXX did hash needs ? */
+ return cfs_hash_djb2_hash(key, sizeof(__u32), bits);
}
static int nrs_tbf_opcode_hop_keycmp(const void *key, struct hlist_node *hnode)
.o_rule_fini = nrs_tbf_opcode_rule_fini,
};
-static unsigned nrs_tbf_id_hop_hash(struct cfs_hash *hs, const void *key,
- unsigned mask)
+static unsigned int
+nrs_tbf_id_hop_hash(struct cfs_hash *hs, const void *key,
+ const unsigned int bits)
{
- return cfs_hash_djb2_hash(key, sizeof(struct tbf_id), mask);
+ return cfs_hash_djb2_hash(key, sizeof(struct tbf_id), bits);
}
static int nrs_tbf_id_hop_keycmp(const void *key, struct hlist_node *hnode)
MODULE_PARM_DESC(hash_lqs_cur_bits, "the current bits of lqe hash");
static unsigned
-lqe64_hash_hash(struct cfs_hash *hs, const void *key, unsigned mask)
+lqe64_hash_hash(struct cfs_hash *hs, const void *key, const unsigned int bits)
{
- return cfs_hash_64(*((__u64 *)key), 0) & mask;
+ return cfs_hash_64(*((__u64 *)key), bits);
}
static void *lqe64_hash_key(struct hlist_node *hnode)