From 8e8f55a61d2f90569e1ab00963a6ce431c41377f Mon Sep 17 00:00:00 2001 From: jacob Date: Thu, 19 May 2005 20:56:34 +0000 Subject: [PATCH] b=4855 r=phil (original patch) handle crc32_le being a module or disabled. --- lustre/include/liblustre.h | 27 --------------------------- lustre/include/linux/obd_support.h | 32 ++++++++++++++++++++++++++++++++ lustre/llite/rw.c | 1 - lustre/osc/osc_request.c | 1 - lustre/ost/ost_handler.c | 1 - 5 files changed, 32 insertions(+), 30 deletions(-) diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h index e6d83de..d618a40 100644 --- a/lustre/include/liblustre.h +++ b/lustre/include/liblustre.h @@ -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. diff --git a/lustre/include/linux/obd_support.h b/lustre/include/linux/obd_support.h index afb43ac..f833f72 100644 --- a/lustre/include/linux/obd_support.h +++ b/lustre/include/linux/obd_support.h @@ -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 +#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 diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index b698b05..005a21d 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -40,7 +40,6 @@ #include #include #include -#include #define DEBUG_SUBSYSTEM S_LLITE diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 217aca1..01588c7 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -44,7 +44,6 @@ # else # include # endif -# include #else /* __KERNEL__ */ # include #endif diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index f1dd396..4f5cf14 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -36,7 +36,6 @@ #define DEBUG_SUBSYSTEM S_OST #include -#include #include #include #include -- 1.8.3.1