/** rehash workitem */
struct work_struct hs_rehash_work;
/** refcount on this hash table */
- atomic_t hs_refcount;
+ struct kref hs_refcount;
/** rehash buckets-table */
struct cfs_hash_bucket **hs_rehash_buckets;
#if CFS_HASH_DEBUG_LEVEL >= CFS_HASH_DEBUG_1
strlcpy(hs->hs_name, name, len);
hs->hs_flags = flags;
- atomic_set(&hs->hs_refcount, 1);
+ kref_init(&hs->hs_refcount);
atomic_set(&hs->hs_count, 0);
cfs_hash_lock_setup(hs);
* Cleanup libcfs hash @hs.
*/
static void
-cfs_hash_destroy(struct cfs_hash *hs)
+cfs_hash_destroy(struct kref *kref)
{
+ struct cfs_hash *hs = container_of(kref, struct cfs_hash, hs_refcount);
struct hlist_node *hnode;
struct hlist_node *pos;
- struct cfs_hash_bd bd;
+ struct cfs_hash_bd bd;
int i;
ENTRY;
struct cfs_hash *cfs_hash_getref(struct cfs_hash *hs)
{
- if (atomic_inc_not_zero(&hs->hs_refcount))
+ if (kref_get_unless_zero(&hs->hs_refcount))
return hs;
return NULL;
}
void cfs_hash_putref(struct cfs_hash *hs)
{
- if (atomic_dec_and_test(&hs->hs_refcount))
- cfs_hash_destroy(hs);
+ kref_put(&hs->hs_refcount, cfs_hash_destroy);
}
EXPORT_SYMBOL(cfs_hash_putref);