Files
scoutfs/kmod/src/hash.h
Zach Brown aee017903b 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>
2019-06-24 09:58:22 -07:00

16 lines
335 B
C

#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