[DRBD-cvs] r1789 - in branches/drbd-0.7: drbd scripts

www-data www-data at garcon.linbit.com
Mon May 9 10:13:39 CEST 2005


Author: phil
Date: 2005-05-09 10:13:38 +0200 (Mon, 09 May 2005)
New Revision: 1789

Modified:
   branches/drbd-0.7/drbd/drbd_bitmap.c
   branches/drbd-0.7/drbd/drbd_compat_types.h
   branches/drbd-0.7/scripts/adjust_drbd_config_h.sh
Log:
Patch by Paul Clement:
* Makes DRBD work on PPC64 - Linux-2.4.x 


Modified: branches/drbd-0.7/drbd/drbd_bitmap.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_bitmap.c	2005-04-26 19:43:54 UTC (rev 1788)
+++ branches/drbd-0.7/drbd/drbd_bitmap.c	2005-05-09 08:13:38 UTC (rev 1789)
@@ -33,6 +33,49 @@
 #include <linux/drbd.h>
 #include "drbd_int.h"
 
+/* special handling for ppc64 on 2.4 kernel -- find_next_bit is not exported
+ * so we include it here (verbatim, from linux 2.4.21 sources) */
+#if defined(__powerpc64__) && LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+
+unsigned long find_next_bit(unsigned long *addr, unsigned long size, unsigned long offset)
+{
+        unsigned long *p = addr + (offset >> 6);
+        unsigned long result = offset & ~63UL;
+        unsigned long tmp;
+
+        if (offset >= size)
+                return size;
+        size -= result;
+        offset &= 63UL;
+        if (offset) {
+                tmp = *(p++);
+                tmp &= (~0UL << offset);
+                if (size < 64)
+                        goto found_first;
+                if (tmp)
+                        goto found_middle;
+                size -= 64;
+                result += 64;
+        }
+        while (size & ~63UL) {
+                if ((tmp = *(p++)))
+                        goto found_middle;
+                result += 64;
+                size -= 64;
+        }
+        if (!size)
+                return result;
+        tmp = *p;
+
+found_first:
+        tmp &= (~0UL >> (64 - size));
+        if (tmp == 0UL)        /* Are any bits set? */
+                return result + size; /* Nope. */
+found_middle:
+        return result + __ffs(tmp);
+}
+#endif /* NEED_PPC64_WORKAROUND */
+
 /* OPAQUE outside this file!
  * interface defined in drbd_int.h
  *

Modified: branches/drbd-0.7/drbd/drbd_compat_types.h
===================================================================
--- branches/drbd-0.7/drbd/drbd_compat_types.h	2005-04-26 19:43:54 UTC (rev 1788)
+++ branches/drbd-0.7/drbd/drbd_compat_types.h	2005-05-09 08:13:38 UTC (rev 1789)
@@ -296,8 +296,8 @@
 #undef _x10000
 #undef _xSHIFT
 
-#else
-#warning "You probabely need to copy find_next_bit() from a 2.6.x kernel."
+#elif !defined(__powerpc64__) /* ppc64 is taken care of, see drbd_bitmap.c */
+#warning "You probably need to copy find_next_bit() from a 2.6.x kernel."
 #warning "Or enable low performance generic C-code"
 #warning "(USE_GENERIC_FIND_NEXT_BIT in drbd_config.h)"
 #endif

Modified: branches/drbd-0.7/scripts/adjust_drbd_config_h.sh
===================================================================
--- branches/drbd-0.7/scripts/adjust_drbd_config_h.sh	2005-04-26 19:43:54 UTC (rev 1788)
+++ branches/drbd-0.7/scripts/adjust_drbd_config_h.sh	2005-05-09 08:13:38 UTC (rev 1789)
@@ -59,7 +59,13 @@
     cat 2>/dev/null $KDIR/include/asm{,/arch}/bitops.h |
     grep_q 'find_next_bit'
   then
-    have_find_next_bit=1
+    # on ppc64, it's declared but not exported, so we use our own copy
+    if grep_q '^CONFIG_PPC64=y' $KDIR/.config
+    then
+      have_find_next_bit=0
+    else
+      have_find_next_bit=1
+    fi
   else
     have_find_next_bit=0
   fi



More information about the drbd-cvs mailing list