spin_lock_init(&hash_body->lchb_lock); /* initialize the body lock */
- for(i =0 ; i < hash_body->lchb_hash_max_size; i++) {
+ for(i = 0 ; i < hash_body->lchb_hash_max_size; i++) {
/* initial the bucket lock and list_head */
INIT_HLIST_HEAD(&hash_body->lchb_hash_tables[i].lhb_head);
spin_lock_init(&hash_body->lchb_hash_tables[i].lhb_lock);
struct lustre_hash_operations *hop = hash_body->lchb_hash_operations;
ENTRY;
+ LASSERT(hlist_unhashed(actual_hnode));
hashent = hop->lustre_hashfn(hash_body, key);
/* get the hash-bucket and lock it */
struct lustre_hash_operations *hop = hash_body->lchb_hash_operations;
ENTRY;
+ LASSERT(hlist_unhashed(actual_hnode));
+
hashent = hop->lustre_hashfn(hash_body, key);
/* get the hashbucket and lock it */
key);
if (hash_item == NULL) {
+ spin_unlock(&bucket->lhb_lock);
RETURN(-ENOENT);
}
RETURN(hash);
}
+/* Note, it is impossible to find an export that is in failed state with
+ * this function */
int uuid_hash_key_compare(void *key, struct hlist_node *compared_hnode)
{
struct obd_export *export = NULL;
compared_uuid = &export->exp_client_uuid;
- RETURN(obd_uuid_equals(uuid_key, compared_uuid));
+ RETURN(obd_uuid_equals(uuid_key, compared_uuid) &&
+ !export->exp_failed);
}
void * uuid_export_refcount_get(struct hlist_node * actual_hnode)
__u32 nid_hashfn(struct lustre_class_hash_body *hash_body, void * key)
{
__u32 hash = 5381;
- lnet_nid_t *nid_key = NULL;
- int c;
- char *ptr = NULL;
+ int i;
+ char *ptr = key;
LASSERT(key != NULL);
- nid_key = (lnet_nid_t*)key;
- ptr = libcfs_nid2str(*nid_key);
-
- while ((c = *ptr++)) {
- hash = hash * 33 + c;
- }
+ for(i = 0 ; i < sizeof(lnet_nid_t) ; i ++)
+ hash = hash * 33 + ptr[i];
hash &= (hash_body->lchb_hash_max_size - 1);
RETURN(hash);
}
+/* Note, it is impossible to find an export that is in failed state with
+ * this function */
int nid_hash_key_compare(void *key, struct hlist_node *compared_hnode)
{
struct obd_export *export = NULL;
lnet_nid_t *nid_key = NULL;
- int retval = 0;
LASSERT( key != NULL);
export = hlist_entry(compared_hnode, struct obd_export, exp_nid_hash);
- if (strcmp(obd_export_nid2str(export), libcfs_nid2str(*nid_key)) == 0)
- retval = 1;
-
- return retval;
+ return (export->exp_connection->c_peer.nid == *nid_key &&
+ !export->exp_failed);
}
-void * nid_export_refcount_get(struct hlist_node * actual_hnode)
+void *nid_export_refcount_get(struct hlist_node *actual_hnode)
{
struct obd_export *export = NULL;
RETURN(export);
}
-void nid_export_refcount_put(struct hlist_node * actual_hnode)
+void nid_export_refcount_put(struct hlist_node *actual_hnode)
{
struct obd_export *export = NULL;
__u32 conn_hashfn(struct lustre_class_hash_body *hash_body, void * key)
{
__u32 hash = 5381;
- lnet_process_id_t *conn_key = NULL;
- char *ptr = NULL;
- int c;
+ char *ptr = key;
+ int i;
LASSERT(key != NULL);
- conn_key = (lnet_process_id_t*)key;
- ptr = libcfs_id2str(*conn_key);
-
- while ((c = *ptr++)) {
- hash = hash * 33 + c;
- }
+ for(i = 0 ; i < sizeof(lnet_process_id_t) ; i ++)
+ hash = hash * 33 + ptr[i];
hash &= (hash_body->lchb_hash_max_size - 1);
{
struct ptlrpc_connection *c = NULL;
lnet_process_id_t *conn_key = NULL;
- int retval = 0;
LASSERT( key != NULL);
c = hlist_entry(compared_hnode, struct ptlrpc_connection, c_hash);
- if (conn_key->nid == c->c_peer.nid &&
- conn_key->pid == c->c_peer.pid)
- retval = 1;
-
- return retval;
+ return (conn_key->nid == c->c_peer.nid &&
+ conn_key->pid == c->c_peer.pid);
}
-void * conn_refcount_get(struct hlist_node * actual_hnode)
+void *conn_refcount_get(struct hlist_node *actual_hnode)
{
struct ptlrpc_connection *c = NULL;
RETURN(c);
}
-void conn_refcount_put(struct hlist_node * actual_hnode)
+void conn_refcount_put(struct hlist_node *actual_hnode)
{
struct ptlrpc_connection *c = NULL;