Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
LU-13127 ptlrpc: prefer crc32_le() over CryptoAPI
[fs/lustre-release.git]
/
lustre
/
ptlrpc
/
pack_generic.c
diff --git
a/lustre/ptlrpc/pack_generic.c
b/lustre/ptlrpc/pack_generic.c
index
0e382c4
..
33b491c
100644
(file)
--- a/
lustre/ptlrpc/pack_generic.c
+++ b/
lustre/ptlrpc/pack_generic.c
@@
-40,9
+40,7
@@
#define DEBUG_SUBSYSTEM S_RPC
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef CONFIG_CRYPTO_CRC32
#include <linux/crc32.h>
#include <linux/crc32.h>
-#endif
#include <libcfs/libcfs.h>
#include <libcfs/libcfs.h>
@@
-1387,13
+1385,16
@@
__u32 lustre_msg_calc_cksum(struct lustre_msg *msg, __u32 buf)
__u32 crc;
LASSERTF(pb != NULL, "invalid msg %p: no ptlrpc body!\n", msg);
__u32 crc;
LASSERTF(pb != NULL, "invalid msg %p: no ptlrpc body!\n", msg);
-#ifdef CONFIG_CRYPTO_CRC32
+#if IS_ENABLED(CONFIG_CRC32)
+ /* about 10x faster than crypto_hash for small buffers */
+ crc = crc32_le(~(__u32)0, (unsigned char *)pb, len);
+#elif IS_ENABLED(CONFIG_CRYPTO_CRC32)
unsigned int hsize = 4;
cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32, (unsigned char *)pb,
len, NULL, 0, (unsigned char *)&crc,
&hsize);
#else
unsigned int hsize = 4;
cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32, (unsigned char *)pb,
len, NULL, 0, (unsigned char *)&crc,
&hsize);
#else
- crc = crc32_le(~(__u32)0, (unsigned char *)pb, len);
+#error "need either CONFIG_CRC32 or CONFIG_CRYPTO_CRC32 enabled in the kernel"
#endif
return crc;
}
#endif
return crc;
}