[Ocfs2-commits] jlbec commits r1827 - in trunk: fs/ocfs2/cluster vendor/redhat

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Jan 21 17:09:02 CST 2005


Author: jlbec
Date: 2005-01-21 17:09:00 -0600 (Fri, 21 Jan 2005)
New Revision: 1827

Modified:
   trunk/fs/ocfs2/cluster/cl_compat.h
   trunk/fs/ocfs2/cluster/nodemanager.c
   trunk/fs/ocfs2/cluster/nodemanager.h
   trunk/vendor/redhat/
Log:

o Use hweight_long(), we're checking longs.
o Make a compat version for 2.4.



Modified: trunk/fs/ocfs2/cluster/cl_compat.h
===================================================================
--- trunk/fs/ocfs2/cluster/cl_compat.h	2005-01-21 22:53:53 UTC (rev 1826)
+++ trunk/fs/ocfs2/cluster/cl_compat.h	2005-01-21 23:09:00 UTC (rev 1827)
@@ -1,7 +1,7 @@
 /* -*- mode: c; c-basic-offset: 8; -*-
  * vim: noexpandtab sw=8 ts=8 sts=0:
  *
- * dlm_compat.h
+ * cl_compat.h
  *
  * Compatibility stuff for 2.4
  *
@@ -117,6 +117,27 @@
 
 #define blk_run_address_space(throwaway) run_task_queue(&tq_disk)
 
+static int unsigned long generic_hweight64(u64 w)
+{
+#if BITS_PER_LONG < 64
+	return generic_hweight32((unsigned int)(w >> 32)) +
+		generic_hweight32((unsigned int)w);
+#else
+	u64 res;
+	res = (w & 0x5555555555555555) + ((w >> 1) & 0x5555555555555555);
+	res = (res & 0x3333333333333333) + ((res >> 2) & 0x3333333333333333);
+	res = (res & 0x0F0F0F0F0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F0F0F0F0F);
+	res = (res & 0x00FF00FF00FF00FF) + ((res >> 8) & 0x00FF00FF00FF00FF);
+	res = (res & 0x0000FFFF0000FFFF) + ((res >> 16) & 0x0000FFFF0000FFFF);
+	return (res & 0x00000000FFFFFFFF) + ((res >> 32) & 0x00000000FFFFFFFF);
+#endif
+}
+
+static inline unsigned long hweight_long(unsigned long w)
+{
+	return sizeof(w) == 4 ? generic_hweight32(w) : generic_hweight64(w);
+}
+
 #else  /* LINUX_VERSION_CODE < 2.6 */
 
 static inline int ocfs_dev_bits(dev_t dev)

Modified: trunk/fs/ocfs2/cluster/nodemanager.c
===================================================================
--- trunk/fs/ocfs2/cluster/nodemanager.c	2005-01-21 22:53:53 UTC (rev 1826)
+++ trunk/fs/ocfs2/cluster/nodemanager.c	2005-01-21 23:09:00 UTC (rev 1827)
@@ -730,7 +730,7 @@
 
 	spin_lock(&cluster.bitmap_lock); 
 	for (i=0; i<ARRAY_SIZE(cluster.node_bitmap); i++)
-		num_nodes += nm_hweight(cluster.node_bitmap[i]);
+		num_nodes += hweight_long(cluster.node_bitmap[i]);
 	spin_unlock(&cluster.bitmap_lock);
 
 	return sprintf(buf, "0: %d", num_nodes);
@@ -744,7 +744,7 @@
 
 	spin_lock(&cluster.bitmap_lock);
 	for (i=0; i<ARRAY_SIZE(cluster.group_bitmap); i++)
-		num_groups += nm_hweight(cluster.group_bitmap[i]);
+		num_groups += hweight_long(cluster.group_bitmap[i]);
 	spin_unlock(&cluster.bitmap_lock);
 
 	return sprintf(buf, "0: %d", num_groups);
@@ -763,7 +763,7 @@
 
 	spin_lock(&g->bitmap_lock);
 	for (i=0; i<ARRAY_SIZE(g->slot_bitmap); i++)
-		num_nodes += nm_hweight(g->slot_bitmap[i]);
+		num_nodes += hweight_long(g->slot_bitmap[i]);
 	spin_unlock(&g->bitmap_lock);
 
 	return num_nodes;

Modified: trunk/fs/ocfs2/cluster/nodemanager.h
===================================================================
--- trunk/fs/ocfs2/cluster/nodemanager.h	2005-01-21 22:53:53 UTC (rev 1826)
+++ trunk/fs/ocfs2/cluster/nodemanager.h	2005-01-21 23:09:00 UTC (rev 1827)
@@ -33,16 +33,7 @@
 #include "ocfs2_nodemanager.h"
 
 
-#if BITS_PER_LONG == 32
-# define nm_hweight hweight32
-#elif BITS_PER_LONG == 64
-# define nm_hweight hweight64
-#else
-# error BITS_PER_LONG is something awful
-#endif
 
-
-
 struct _nm_ctxt
 {
 	int dummy;


Property changes on: trunk/vendor/redhat
___________________________________________________________________
Name: svn:ignore
   - ocfs2-*.spec

   + ocfs2-*.spec-generic




More information about the Ocfs2-commits mailing list