Whamcloud - gitweb
b=4855
authorjacob <jacob>
Thu, 19 May 2005 20:56:34 +0000 (20:56 +0000)
committerjacob <jacob>
Thu, 19 May 2005 20:56:34 +0000 (20:56 +0000)
r=phil (original patch)

handle crc32_le being a module or disabled.

lustre/include/liblustre.h
lustre/include/linux/obd_support.h
lustre/llite/rw.c
lustre/osc/osc_request.c
lustre/ost/ost_handler.c

index e6d83de..d618a40 100644 (file)
@@ -76,33 +76,6 @@ typedef unsigned short umode_t;
 
 #endif
 
-/* crc32_le lifted from the Linux kernel, which had the following to say:
- *
- * This code is in the public domain; copyright abandoned.
- * Liability for non-performance of this code is limited to the amount
- * you paid for it.  Since it is distributed for free, your refund will
- * be very very small.  If it breaks, you get to keep both pieces.
- */
-#define CRCPOLY_LE 0xedb88320
-/**
- * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
- * @crc - seed value for computation.  ~0 for Ethernet, sometimes 0 for
- *        other uses, or the previous crc32 value if computing incrementally.
- * @p   - pointer to buffer over which CRC is run
- * @len - length of buffer @p
- */
-static inline __u32 crc32_le(__u32 crc, unsigned char const *p, size_t len)
-{
-        int i;
-        while (len--) {
-                crc ^= *p++;
-                for (i = 0; i < 8; i++)
-                        crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
-        }
-        return crc;
-}
-
-
 /* This is because lprocfs_status.h gets included here indirectly.  It would
  * be much better to just avoid lprocfs being included into liblustre entirely
  * but that requires more header surgery than I can handle right now.
index afb43ac..f833f72 100644 (file)
@@ -206,6 +206,38 @@ do {                                                                         \
        }                                                                     \
 } while(0)
 
+/* Prefer the kernel's version, if it exports it, because it might be
+ * optimized for this CPU. */
+#if defined(__KERNEL__) && (defined(CONFIG_CRC32) || defined(CONFIG_CRC32_MODULE))
+# include <linux/crc32.h>
+#else
+/* crc32_le lifted from the Linux kernel, which had the following to say:
+ *
+ * This code is in the public domain; copyright abandoned.
+ * Liability for non-performance of this code is limited to the amount
+ * you paid for it.  Since it is distributed for free, your refund will
+ * be very very small.  If it breaks, you get to keep both pieces.
+ */
+#define CRCPOLY_LE 0xedb88320
+/**
+ * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
+ * @crc - seed value for computation.  ~0 for Ethernet, sometimes 0 for
+ *        other uses, or the previous crc32 value if computing incrementally.
+ * @p   - pointer to buffer over which CRC is run
+ * @len - length of buffer @p
+ */
+static inline __u32 crc32_le(__u32 crc, unsigned char const *p, size_t len)
+{
+        int i;
+        while (len--) {
+                crc ^= *p++;
+                for (i = 0; i < 8; i++)
+                        crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
+        }
+        return crc;
+}
+#endif
+
 #ifdef __KERNEL__
 /* The idea here is to synchronise two threads to force a race. The
  * first thread that calls this with a matching fail_loc is put to
index b698b05..005a21d 100644 (file)
@@ -40,7 +40,6 @@
 #include <linux/mm.h>
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
-#include <linux/crc32.h>
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
index 217aca1..01588c7 100644 (file)
@@ -44,7 +44,6 @@
 # else
 #  include <linux/locks.h>
 # endif
-# include <linux/crc32.h>
 #else /* __KERNEL__ */
 # include <liblustre.h>
 #endif
index f1dd396..4f5cf14 100644 (file)
@@ -36,7 +36,6 @@
 #define DEBUG_SUBSYSTEM S_OST
 
 #include <linux/module.h>
-#include <linux/crc32.h>
 #include <linux/obd_ost.h>
 #include <linux/lustre_net.h>
 #include <linux/lustre_dlm.h>