Whamcloud - gitweb
LU-1346 libcfs: cleanup waitq related primitives
[fs/lustre-release.git] / libcfs / libcfs / hash.c
index cb260a4..b8aaa12 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, Whamcloud, Inc.
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -126,31 +126,31 @@ cfs_hash_nl_unlock(cfs_hash_lock_t *lock, int exclusive) {}
 static inline void
 cfs_hash_spin_lock(cfs_hash_lock_t *lock, int exclusive)
 {
-        cfs_spin_lock(&lock->spin);
+       spin_lock(&lock->spin);
 }
 
 static inline void
 cfs_hash_spin_unlock(cfs_hash_lock_t *lock, int exclusive)
 {
-        cfs_spin_unlock(&lock->spin);
+       spin_unlock(&lock->spin);
 }
 
 static inline void
 cfs_hash_rw_lock(cfs_hash_lock_t *lock, int exclusive)
 {
-        if (!exclusive)
-                cfs_read_lock(&lock->rw);
-        else
-                cfs_write_lock(&lock->rw);
+       if (!exclusive)
+               read_lock(&lock->rw);
+       else
+               write_lock(&lock->rw);
 }
 
 static inline void
 cfs_hash_rw_unlock(cfs_hash_lock_t *lock, int exclusive)
 {
-        if (!exclusive)
-                cfs_read_unlock(&lock->rw);
-        else
-                cfs_write_unlock(&lock->rw);
+       if (!exclusive)
+               read_unlock(&lock->rw);
+       else
+               write_unlock(&lock->rw);
 }
 
 /** No lock hash */
@@ -210,15 +210,15 @@ static cfs_hash_lock_ops_t cfs_hash_nr_bkt_rw_lops =
 static void
 cfs_hash_lock_setup(cfs_hash_t *hs)
 {
-        if (cfs_hash_with_no_lock(hs)) {
-                hs->hs_lops = &cfs_hash_nl_lops;
+       if (cfs_hash_with_no_lock(hs)) {
+               hs->hs_lops = &cfs_hash_nl_lops;
 
-        } else if (cfs_hash_with_no_bktlock(hs)) {
-                hs->hs_lops = &cfs_hash_nbl_lops;
-                cfs_spin_lock_init(&hs->hs_lock.spin);
+       } else if (cfs_hash_with_no_bktlock(hs)) {
+               hs->hs_lops = &cfs_hash_nbl_lops;
+               spin_lock_init(&hs->hs_lock.spin);
 
-        } else if (cfs_hash_with_rehash(hs)) {
-                cfs_rwlock_init(&hs->hs_lock.rw);
+       } else if (cfs_hash_with_rehash(hs)) {
+               rwlock_init(&hs->hs_lock.rw);
 
                 if (cfs_hash_with_rw_bktlock(hs))
                         hs->hs_lops = &cfs_hash_bkt_rw_lops;
@@ -492,7 +492,7 @@ cfs_hash_bd_get(cfs_hash_t *hs, const void *key, cfs_hash_bd_t *bd)
                                      hs->hs_rehash_bits, key, bd);
         }
 }
-CFS_EXPORT_SYMBOL(cfs_hash_bd_get);
+EXPORT_SYMBOL(cfs_hash_bd_get);
 
 static inline void
 cfs_hash_bd_dep_record(cfs_hash_t *hs, cfs_hash_bd_t *bd, int dep_cur)
@@ -506,12 +506,12 @@ cfs_hash_bd_dep_record(cfs_hash_t *hs, cfs_hash_bd_t *bd, int dep_cur)
                    max(warn_on_depth, hs->hs_dep_max) >= dep_cur))
                 return;
 
-        cfs_spin_lock(&hs->hs_dep_lock);
-        hs->hs_dep_max  = dep_cur;
-        hs->hs_dep_bkt  = bd->bd_bucket->hsb_index;
-        hs->hs_dep_off  = bd->bd_offset;
-        hs->hs_dep_bits = hs->hs_cur_bits;
-        cfs_spin_unlock(&hs->hs_dep_lock);
+       spin_lock(&hs->hs_dep_lock);
+       hs->hs_dep_max  = dep_cur;
+       hs->hs_dep_bkt  = bd->bd_bucket->hsb_index;
+       hs->hs_dep_off  = bd->bd_offset;
+       hs->hs_dep_bits = hs->hs_cur_bits;
+       spin_unlock(&hs->hs_dep_lock);
 
        cfs_wi_schedule(cfs_sched_rehash, &hs->hs_dep_wi);
 # endif
@@ -535,7 +535,7 @@ cfs_hash_bd_add_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd,
         if (!cfs_hash_with_no_itemref(hs))
                 cfs_hash_get(hs, hnode);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_bd_add_locked);
+EXPORT_SYMBOL(cfs_hash_bd_add_locked);
 
 void
 cfs_hash_bd_del_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd,
@@ -556,7 +556,7 @@ cfs_hash_bd_del_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd,
         if (!cfs_hash_with_no_itemref(hs))
                 cfs_hash_put_locked(hs, hnode);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_bd_del_locked);
+EXPORT_SYMBOL(cfs_hash_bd_del_locked);
 
 void
 cfs_hash_bd_move_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd_old,
@@ -585,7 +585,7 @@ cfs_hash_bd_move_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd_old,
         if (unlikely(nbkt->hsb_version == 0))
                 nbkt->hsb_version++;
 }
-CFS_EXPORT_SYMBOL(cfs_hash_bd_move_locked);
+EXPORT_SYMBOL(cfs_hash_bd_move_locked);
 
 enum {
         /** always set, for sanity (avoid ZERO intent) */
@@ -662,7 +662,15 @@ cfs_hash_bd_lookup_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, const void *key)
         return cfs_hash_bd_lookup_intent(hs, bd, key, NULL,
                                          CFS_HS_LOOKUP_IT_FIND);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_bd_lookup_locked);
+EXPORT_SYMBOL(cfs_hash_bd_lookup_locked);
+
+cfs_hlist_node_t *
+cfs_hash_bd_peek_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, const void *key)
+{
+       return cfs_hash_bd_lookup_intent(hs, bd, key, NULL,
+                                        CFS_HS_LOOKUP_IT_PEEK);
+}
+EXPORT_SYMBOL(cfs_hash_bd_peek_locked);
 
 cfs_hlist_node_t *
 cfs_hash_bd_findadd_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd,
@@ -673,7 +681,7 @@ cfs_hash_bd_findadd_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd,
                                          CFS_HS_LOOKUP_IT_ADD |
                                          (!noref * CFS_HS_LOOKUP_MASK_REF));
 }
-CFS_EXPORT_SYMBOL(cfs_hash_bd_findadd_locked);
+EXPORT_SYMBOL(cfs_hash_bd_findadd_locked);
 
 cfs_hlist_node_t *
 cfs_hash_bd_finddel_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd,
@@ -683,7 +691,7 @@ cfs_hash_bd_finddel_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd,
         return cfs_hash_bd_lookup_intent(hs, bd, key, hnode,
                                          CFS_HS_LOOKUP_IT_FINDDEL);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_bd_finddel_locked);
+EXPORT_SYMBOL(cfs_hash_bd_finddel_locked);
 
 static void
 cfs_hash_multi_bd_lock(cfs_hash_t *hs, cfs_hash_bd_t *bds,
@@ -832,21 +840,21 @@ cfs_hash_dual_bd_get(cfs_hash_t *hs, const void *key, cfs_hash_bd_t *bds)
 
         cfs_hash_bd_order(&bds[0], &bds[1]);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_dual_bd_get);
+EXPORT_SYMBOL(cfs_hash_dual_bd_get);
 
 void
 cfs_hash_dual_bd_lock(cfs_hash_t *hs, cfs_hash_bd_t *bds, int excl)
 {
         cfs_hash_multi_bd_lock(hs, bds, 2, excl);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_dual_bd_lock);
+EXPORT_SYMBOL(cfs_hash_dual_bd_lock);
 
 void
 cfs_hash_dual_bd_unlock(cfs_hash_t *hs, cfs_hash_bd_t *bds, int excl)
 {
         cfs_hash_multi_bd_unlock(hs, bds, 2, excl);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_dual_bd_unlock);
+EXPORT_SYMBOL(cfs_hash_dual_bd_unlock);
 
 cfs_hlist_node_t *
 cfs_hash_dual_bd_lookup_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds,
@@ -854,7 +862,7 @@ cfs_hash_dual_bd_lookup_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds,
 {
         return cfs_hash_multi_bd_lookup_locked(hs, bds, 2, key);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_dual_bd_lookup_locked);
+EXPORT_SYMBOL(cfs_hash_dual_bd_lookup_locked);
 
 cfs_hlist_node_t *
 cfs_hash_dual_bd_findadd_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds,
@@ -864,7 +872,7 @@ cfs_hash_dual_bd_findadd_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds,
         return cfs_hash_multi_bd_findadd_locked(hs, bds, 2, key,
                                                 hnode, noref);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_dual_bd_findadd_locked);
+EXPORT_SYMBOL(cfs_hash_dual_bd_findadd_locked);
 
 cfs_hlist_node_t *
 cfs_hash_dual_bd_finddel_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds,
@@ -872,7 +880,7 @@ cfs_hash_dual_bd_finddel_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds,
 {
         return cfs_hash_multi_bd_finddel_locked(hs, bds, 2, key, hnode);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_dual_bd_finddel_locked);
+EXPORT_SYMBOL(cfs_hash_dual_bd_finddel_locked);
 
 static void
 cfs_hash_buckets_free(cfs_hash_bucket_t **buckets,
@@ -936,14 +944,14 @@ cfs_hash_buckets_realloc(cfs_hash_t *hs, cfs_hash_bucket_t **old_bkts,
                     cfs_hash_with_no_bktlock(hs))
                         continue;
 
-                if (cfs_hash_with_rw_bktlock(hs))
-                        cfs_rwlock_init(&new_bkts[i]->hsb_lock.rw);
-                else if (cfs_hash_with_spin_bktlock(hs))
-                        cfs_spin_lock_init(&new_bkts[i]->hsb_lock.spin);
-                else
-                        LBUG(); /* invalid use-case */
-        }
-        return new_bkts;
+               if (cfs_hash_with_rw_bktlock(hs))
+                       rwlock_init(&new_bkts[i]->hsb_lock.rw);
+               else if (cfs_hash_with_spin_bktlock(hs))
+                       spin_lock_init(&new_bkts[i]->hsb_lock.spin);
+               else
+                       LBUG(); /* invalid use-case */
+       }
+       return new_bkts;
 }
 
 /**
@@ -960,45 +968,45 @@ static int cfs_hash_rehash_worker(cfs_workitem_t *wi);
 #if CFS_HASH_DEBUG_LEVEL >= CFS_HASH_DEBUG_1
 static int cfs_hash_dep_print(cfs_workitem_t *wi)
 {
-        cfs_hash_t *hs = container_of(wi, cfs_hash_t, hs_dep_wi);
-        int         dep;
-        int         bkt;
-        int         off;
-        int         bits;
-
-        cfs_spin_lock(&hs->hs_dep_lock);
-        dep  = hs->hs_dep_max;
-        bkt  = hs->hs_dep_bkt;
-        off  = hs->hs_dep_off;
-        bits = hs->hs_dep_bits;
-        cfs_spin_unlock(&hs->hs_dep_lock);
-
-        LCONSOLE_WARN("#### HASH %s (bits: %d): max depth %d at bucket %d/%d\n",
-                      hs->hs_name, bits, dep, bkt, off);
-        cfs_spin_lock(&hs->hs_dep_lock);
-        hs->hs_dep_bits = 0; /* mark as workitem done */
-        cfs_spin_unlock(&hs->hs_dep_lock);
-        return 0;
+       cfs_hash_t *hs = container_of(wi, cfs_hash_t, hs_dep_wi);
+       int         dep;
+       int         bkt;
+       int         off;
+       int         bits;
+
+       spin_lock(&hs->hs_dep_lock);
+       dep  = hs->hs_dep_max;
+       bkt  = hs->hs_dep_bkt;
+       off  = hs->hs_dep_off;
+       bits = hs->hs_dep_bits;
+       spin_unlock(&hs->hs_dep_lock);
+
+       LCONSOLE_WARN("#### HASH %s (bits: %d): max depth %d at bucket %d/%d\n",
+                     hs->hs_name, bits, dep, bkt, off);
+       spin_lock(&hs->hs_dep_lock);
+       hs->hs_dep_bits = 0; /* mark as workitem done */
+       spin_unlock(&hs->hs_dep_lock);
+       return 0;
 }
 
 static void cfs_hash_depth_wi_init(cfs_hash_t *hs)
 {
-       cfs_spin_lock_init(&hs->hs_dep_lock);
+       spin_lock_init(&hs->hs_dep_lock);
        cfs_wi_init(&hs->hs_dep_wi, hs, cfs_hash_dep_print);
 }
 
 static void cfs_hash_depth_wi_cancel(cfs_hash_t *hs)
 {
        if (cfs_wi_deschedule(cfs_sched_rehash, &hs->hs_dep_wi))
-                return;
+               return;
 
-        cfs_spin_lock(&hs->hs_dep_lock);
-        while (hs->hs_dep_bits != 0) {
-                cfs_spin_unlock(&hs->hs_dep_lock);
-                cfs_cond_resched();
-                cfs_spin_lock(&hs->hs_dep_lock);
-        }
-        cfs_spin_unlock(&hs->hs_dep_lock);
+       spin_lock(&hs->hs_dep_lock);
+       while (hs->hs_dep_bits != 0) {
+               spin_unlock(&hs->hs_dep_lock);
+               cond_resched();
+               spin_lock(&hs->hs_dep_lock);
+       }
+       spin_unlock(&hs->hs_dep_lock);
 }
 
 #else /* CFS_HASH_DEBUG_LEVEL < CFS_HASH_DEBUG_1 */
@@ -1080,7 +1088,7 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits,
         LIBCFS_FREE(hs, offsetof(cfs_hash_t, hs_name[len]));
         RETURN(NULL);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_create);
+EXPORT_SYMBOL(cfs_hash_create);
 
 /**
  * Cleanup libcfs hash @hs.
@@ -1131,10 +1139,10 @@ cfs_hash_destroy(cfs_hash_t *hs)
                                 cfs_hash_exit(hs, hnode);
                         }
                 }
-                LASSERT(bd.bd_bucket->hsb_count == 0);
-                cfs_hash_bd_unlock(hs, &bd, 1);
-                cfs_cond_resched();
-        }
+               LASSERT(bd.bd_bucket->hsb_count == 0);
+               cfs_hash_bd_unlock(hs, &bd, 1);
+               cond_resched();
+       }
 
         LASSERT(cfs_atomic_read(&hs->hs_count) == 0);
 
@@ -1153,14 +1161,14 @@ cfs_hash_t *cfs_hash_getref(cfs_hash_t *hs)
                 return hs;
         return NULL;
 }
-CFS_EXPORT_SYMBOL(cfs_hash_getref);
+EXPORT_SYMBOL(cfs_hash_getref);
 
 void cfs_hash_putref(cfs_hash_t *hs)
 {
         if (cfs_atomic_dec_and_test(&hs->hs_refcount))
                 cfs_hash_destroy(hs);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_putref);
+EXPORT_SYMBOL(cfs_hash_putref);
 
 static inline int
 cfs_hash_rehash_bits(cfs_hash_t *hs)
@@ -1231,7 +1239,7 @@ cfs_hash_add(cfs_hash_t *hs, const void *key, cfs_hlist_node_t *hnode)
         if (bits > 0)
                 cfs_hash_rehash(hs, cfs_hash_rehash_inline(hs));
 }
-CFS_EXPORT_SYMBOL(cfs_hash_add);
+EXPORT_SYMBOL(cfs_hash_add);
 
 static cfs_hlist_node_t *
 cfs_hash_find_or_add(cfs_hash_t *hs, const void *key,
@@ -1271,7 +1279,7 @@ cfs_hash_add_unique(cfs_hash_t *hs, const void *key, cfs_hlist_node_t *hnode)
         return cfs_hash_find_or_add(hs, key, hnode, 1) != hnode ?
                -EALREADY : 0;
 }
-CFS_EXPORT_SYMBOL(cfs_hash_add_unique);
+EXPORT_SYMBOL(cfs_hash_add_unique);
 
 /**
  * Add item @hnode to libcfs hash @hs using @key.  If this @key
@@ -1287,7 +1295,7 @@ cfs_hash_findadd_unique(cfs_hash_t *hs, const void *key,
 
         return cfs_hash_object(hs, hnode);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_findadd_unique);
+EXPORT_SYMBOL(cfs_hash_findadd_unique);
 
 /**
  * Delete item @hnode from the libcfs hash @hs using @key.  The @key
@@ -1328,7 +1336,7 @@ cfs_hash_del(cfs_hash_t *hs, const void *key, cfs_hlist_node_t *hnode)
 
         return obj;
 }
-CFS_EXPORT_SYMBOL(cfs_hash_del);
+EXPORT_SYMBOL(cfs_hash_del);
 
 /**
  * Delete item given @key in libcfs hash @hs.  The first @key found in
@@ -1341,7 +1349,7 @@ cfs_hash_del_key(cfs_hash_t *hs, const void *key)
 {
         return cfs_hash_del(hs, key, NULL);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_del_key);
+EXPORT_SYMBOL(cfs_hash_del_key);
 
 /**
  * Lookup an item using @key in the libcfs hash @hs and return it.
@@ -1370,7 +1378,7 @@ cfs_hash_lookup(cfs_hash_t *hs, const void *key)
 
         return obj;
 }
-CFS_EXPORT_SYMBOL(cfs_hash_lookup);
+EXPORT_SYMBOL(cfs_hash_lookup);
 
 static void
 cfs_hash_for_each_enter(cfs_hash_t *hs)
@@ -1471,11 +1479,11 @@ cfs_hash_for_each_tight(cfs_hash_t *hs, cfs_hash_for_each_cb_t func,
                 cfs_hash_bd_unlock(hs, &bd, excl);
                 if (loop < CFS_HASH_LOOP_HOG)
                         continue;
-                loop = 0;
-                cfs_hash_unlock(hs, 0);
-                cfs_cond_resched();
-                cfs_hash_lock(hs, 0);
-        }
+               loop = 0;
+               cfs_hash_unlock(hs, 0);
+               cond_resched();
+               cfs_hash_lock(hs, 0);
+       }
  out:
         cfs_hash_unlock(hs, 0);
 
@@ -1514,7 +1522,7 @@ cfs_hash_cond_del(cfs_hash_t *hs, cfs_hash_cond_opt_cb_t func, void *data)
 
         cfs_hash_for_each_tight(hs, cfs_hash_cond_del_locked, &arg, 1);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_cond_del);
+EXPORT_SYMBOL(cfs_hash_cond_del);
 
 void
 cfs_hash_for_each(cfs_hash_t *hs,
@@ -1522,7 +1530,7 @@ cfs_hash_for_each(cfs_hash_t *hs,
 {
         cfs_hash_for_each_tight(hs, func, data, 0);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_for_each);
+EXPORT_SYMBOL(cfs_hash_for_each);
 
 void
 cfs_hash_for_each_safe(cfs_hash_t *hs,
@@ -1530,7 +1538,7 @@ cfs_hash_for_each_safe(cfs_hash_t *hs,
 {
         cfs_hash_for_each_tight(hs, func, data, 1);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_for_each_safe);
+EXPORT_SYMBOL(cfs_hash_for_each_safe);
 
 static int
 cfs_hash_peek(cfs_hash_t *hs, cfs_hash_bd_t *bd,
@@ -1548,7 +1556,7 @@ cfs_hash_is_empty(cfs_hash_t *hs)
         cfs_hash_for_each_tight(hs, cfs_hash_peek, &empty, 0);
         return empty;
 }
-CFS_EXPORT_SYMBOL(cfs_hash_is_empty);
+EXPORT_SYMBOL(cfs_hash_is_empty);
 
 __u64
 cfs_hash_size_get(cfs_hash_t *hs)
@@ -1557,7 +1565,7 @@ cfs_hash_size_get(cfs_hash_t *hs)
                cfs_atomic_read(&hs->hs_count) :
                cfs_hash_for_each_tight(hs, NULL, NULL, 0);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_size_get);
+EXPORT_SYMBOL(cfs_hash_size_get);
 
 /*
  * cfs_hash_for_each_relax:
@@ -1606,11 +1614,11 @@ cfs_hash_for_each_relax(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, void *data)
                                 cfs_hash_bd_unlock(hs, &bd, 0);
                                 cfs_hash_unlock(hs, 0);
 
-                                rc = func(hs, &bd, hnode, data);
-                                if (stop_on_change)
-                                        cfs_hash_put(hs, hnode);
-                                cfs_cond_resched();
-                                count++;
+                               rc = func(hs, &bd, hnode, data);
+                               if (stop_on_change)
+                                       cfs_hash_put(hs, hnode);
+                               cond_resched();
+                               count++;
 
                                 cfs_hash_lock(hs, 0);
                                 cfs_hash_bd_lock(hs, &bd, 0);
@@ -1658,7 +1666,7 @@ cfs_hash_for_each_nolock(cfs_hash_t *hs,
 
         RETURN(0);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_for_each_nolock);
+EXPORT_SYMBOL(cfs_hash_for_each_nolock);
 
 /**
  * For each hash bucket in the libcfs hash @hs call the passed callback
@@ -1694,7 +1702,7 @@ cfs_hash_for_each_empty(cfs_hash_t *hs,
         cfs_hash_for_each_exit(hs);
         RETURN(0);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_for_each_empty);
+EXPORT_SYMBOL(cfs_hash_for_each_empty);
 
 void
 cfs_hash_hlist_for_each(cfs_hash_t *hs, unsigned hindex,
@@ -1723,7 +1731,7 @@ cfs_hash_hlist_for_each(cfs_hash_t *hs, unsigned hindex,
         cfs_hash_for_each_exit(hs);
 }
 
-CFS_EXPORT_SYMBOL(cfs_hash_hlist_for_each);
+EXPORT_SYMBOL(cfs_hash_hlist_for_each);
 
 /*
  * For each item in the libcfs hash @hs which matches the @key call
@@ -1759,7 +1767,7 @@ cfs_hash_for_each_key(cfs_hash_t *hs, const void *key,
         cfs_hash_dual_bd_unlock(hs, bds, 0);
         cfs_hash_unlock(hs, 0);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_for_each_key);
+EXPORT_SYMBOL(cfs_hash_for_each_key);
 
 /**
  * Rehash the libcfs hash @hs to the given @bits.  This can be used
@@ -1790,16 +1798,16 @@ cfs_hash_rehash_cancel_locked(cfs_hash_t *hs)
         }
 
         for (i = 2; cfs_hash_is_rehashing(hs); i++) {
-                cfs_hash_unlock(hs, 1);
-                /* raise console warning while waiting too long */
-                CDEBUG(IS_PO2(i >> 3) ? D_WARNING : D_INFO,
-                       "hash %s is still rehashing, rescheded %d\n",
-                       hs->hs_name, i - 1);
-                cfs_cond_resched();
-                cfs_hash_lock(hs, 1);
-        }
+               cfs_hash_unlock(hs, 1);
+               /* raise console warning while waiting too long */
+               CDEBUG(IS_PO2(i >> 3) ? D_WARNING : D_INFO,
+                      "hash %s is still rehashing, rescheded %d\n",
+                      hs->hs_name, i - 1);
+               cond_resched();
+               cfs_hash_lock(hs, 1);
+       }
 }
-CFS_EXPORT_SYMBOL(cfs_hash_rehash_cancel_locked);
+EXPORT_SYMBOL(cfs_hash_rehash_cancel_locked);
 
 void
 cfs_hash_rehash_cancel(cfs_hash_t *hs)
@@ -1808,7 +1816,7 @@ cfs_hash_rehash_cancel(cfs_hash_t *hs)
         cfs_hash_rehash_cancel_locked(hs);
         cfs_hash_unlock(hs, 1);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_rehash_cancel);
+EXPORT_SYMBOL(cfs_hash_rehash_cancel);
 
 int
 cfs_hash_rehash(cfs_hash_t *hs, int do_rehash)
@@ -1838,7 +1846,7 @@ cfs_hash_rehash(cfs_hash_t *hs, int do_rehash)
 
         return cfs_hash_rehash_worker(&hs->hs_rehash_wi);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_rehash);
+EXPORT_SYMBOL(cfs_hash_rehash);
 
 static int
 cfs_hash_rehash_bd(cfs_hash_t *hs, cfs_hash_bd_t *old)
@@ -1943,11 +1951,11 @@ cfs_hash_rehash_worker(cfs_workitem_t *wi)
                         continue;
                 }
 
-                count = 0;
-                cfs_hash_unlock(hs, 1);
-                cfs_cond_resched();
-                cfs_hash_lock(hs, 1);
-        }
+               count = 0;
+               cfs_hash_unlock(hs, 1);
+               cond_resched();
+               cfs_hash_lock(hs, 1);
+       }
 
         hs->hs_rehash_count++;
 
@@ -2017,7 +2025,7 @@ void cfs_hash_rehash_key(cfs_hash_t *hs, const void *old_key,
         cfs_hash_multi_bd_unlock(hs, bds, 3, 1);
         cfs_hash_unlock(hs, 0);
 }
-CFS_EXPORT_SYMBOL(cfs_hash_rehash_key);
+EXPORT_SYMBOL(cfs_hash_rehash_key);
 
 int cfs_hash_debug_header(char *str, int size)
 {
@@ -2027,7 +2035,7 @@ int cfs_hash_debug_header(char *str, int size)
                  "flags", "rehash", "count", "maxdep", "maxdepb",
                  " distribution");
 }
-CFS_EXPORT_SYMBOL(cfs_hash_debug_header);
+EXPORT_SYMBOL(cfs_hash_debug_header);
 
 static cfs_hash_bucket_t **
 cfs_hash_full_bkts(cfs_hash_t *hs)
@@ -2107,11 +2115,11 @@ int cfs_hash_debug_str(cfs_hash_t *hs, char *str, int size)
                 if (maxdep < bd.bd_bucket->hsb_depmax) {
                         maxdep  = bd.bd_bucket->hsb_depmax;
 #ifdef __KERNEL__
-                        maxdepb = cfs_ffz(~maxdep);
+                       maxdepb = ffz(~maxdep);
 #endif
                 }
                 total += bd.bd_bucket->hsb_count;
-                dist[min(__cfs_fls(bd.bd_bucket->hsb_count/max(theta,1)),7)]++;
+                dist[min(fls(bd.bd_bucket->hsb_count/max(theta,1)),7)]++;
                 cfs_hash_bd_unlock(hs, &bd, 0);
         }
 
@@ -2126,4 +2134,4 @@ int cfs_hash_debug_str(cfs_hash_t *hs, char *str, int size)
 
         return c;
 }
-CFS_EXPORT_SYMBOL(cfs_hash_debug_str);
+EXPORT_SYMBOL(cfs_hash_debug_str);