mirror of
https://github.com/versity/scoutfs.git
synced 2026-06-08 12:42:35 +00:00
scoutfs: add hash helper
Add a quick header which calculates 64bit hashes by calculating the crc of the two halves of a byte region. Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
15
kmod/src/hash.h
Normal file
15
kmod/src/hash.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef _SCOUTFS_HASH_H_
|
||||
#define _SCOUTFS_HASH_H_
|
||||
|
||||
#include <linux/crc32c.h>
|
||||
|
||||
/* XXX replace with xxhash */
|
||||
static inline u64 scoutfs_hash64(const void *data, unsigned int len)
|
||||
{
|
||||
unsigned int half = (len + 1) / 2;
|
||||
|
||||
return crc32c(~0, data, half) |
|
||||
((u64)crc32c(~0, data + len - half, half) << 32);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user