/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2012, 2013, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
struct cfs_hash_hlist_ops;
typedef union {
- cfs_rwlock_t rw; /**< rwlock */
- cfs_spinlock_t spin; /**< spinlock */
+ rwlock_t rw; /**< rwlock */
+ spinlock_t spin; /**< spinlock */
} cfs_hash_lock_t;
/**
* - some extra bytes (caller can require it while creating hash)
*/
typedef struct cfs_hash_bucket {
- cfs_hash_lock_t hsb_lock; /**< bucket lock */
- __u32 hsb_count; /**< current entries */
- __u32 hsb_version; /**< change version */
- unsigned int hsb_index; /**< index of bucket */
- int hsb_depmax; /**< max depth on bucket */
- char hsb_head[0]; /**< hash-head array */
+ cfs_hash_lock_t hsb_lock; /**< bucket lock */
+ __u32 hsb_count; /**< current entries */
+ __u32 hsb_version; /**< change version */
+ unsigned int hsb_index; /**< index of bucket */
+ int hsb_depmax; /**< max depth on bucket */
+ long hsb_head[0]; /**< hash-head array */
} cfs_hash_bucket_t;
/**
cfs_hash_bucket_t **hs_rehash_buckets;
#if CFS_HASH_DEBUG_LEVEL >= CFS_HASH_DEBUG_1
/** serialize debug members */
- cfs_spinlock_t hs_dep_lock;
+ spinlock_t hs_dep_lock;
/** max depth */
unsigned int hs_dep_max;
/** id of the deepest bucket */
void * (*hs_key)(cfs_hlist_node_t *hnode);
/** copy key from @hnode to @key */
void (*hs_keycpy)(cfs_hlist_node_t *hnode, void *key);
- /** compare @key with key of @hnode */
+ /**
+ * compare @key with key of @hnode
+ * returns 1 on a match
+ */
int (*hs_keycmp)(const void *key, cfs_hlist_node_t *hnode);
/** return object address of @hnode, i.e: container_of(...hnode) */
void * (*hs_object)(cfs_hlist_node_t *hnode);
cfs_hlist_node_t *cfs_hash_bd_lookup_locked(cfs_hash_t *hs,
cfs_hash_bd_t *bd, const void *key);
+cfs_hlist_node_t *cfs_hash_bd_peek_locked(cfs_hash_t *hs,
+ cfs_hash_bd_t *bd, const void *key);
cfs_hlist_node_t *cfs_hash_bd_findadd_locked(cfs_hash_t *hs,
cfs_hash_bd_t *bd, const void *key,
cfs_hlist_node_t *hnode,