Whamcloud - gitweb
LU-4423 libcfs: remove IS_PO2 and __is_po2
[fs/lustre-release.git] / libcfs / libcfs / hash.c
index 5027359..228cf0b 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2015, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
  *   table. Also, user can break the iteration by return 1 in callback.
  */
 #include <linux/seq_file.h>
+#include <linux/log2.h>
 
+#include <libcfs/linux/linux-list.h>
 #include <libcfs/libcfs.h>
 
 #if CFS_HASH_DEBUG_LEVEL >= CFS_HASH_DEBUG_1
@@ -801,12 +799,8 @@ cfs_hash_bd_order(struct cfs_hash_bd *bd1, struct cfs_hash_bd *bd2)
         if (rc == 0) {
                 bd2->bd_bucket = NULL;
 
-        } else if (rc > 0) { /* swab bd1 and bd2 */
-               struct cfs_hash_bd tmp;
-
-                tmp = *bd2;
-                *bd2 = *bd1;
-                *bd1 = tmp;
+       } else if (rc > 0) {
+               swap(*bd1, *bd2); /* swab bd1 and bd2 */
         }
 }
 
@@ -1815,7 +1809,7 @@ cfs_hash_rehash_cancel_locked(struct cfs_hash *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,
+               CDEBUG(is_power_of_2(i >> 3) ? D_WARNING : D_INFO,
                       "hash %s is still rehashing, rescheded %d\n",
                       hs->hs_name, i - 1);
                cond_resched();