diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/iscsi.c | 5 | ||||
| -rw-r--r-- | src/server/iscsi.h | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/server/iscsi.c b/src/server/iscsi.c index 925e4e8..c5f796d 100644 --- a/src/server/iscsi.c +++ b/src/server/iscsi.c @@ -185,12 +185,13 @@ static int iscsi_hashmap_resize(iscsi_hashmap *map) */ static inline uint32_t iscsi_hashmap_hash_data(const uint8_t *data, const size_t len) { + const uint64_t *hash_data = (const uint64_t *) data; size_t num_blocks = iscsi_align(len, ISCSI_HASHMAP_KEY_ALIGN) >> ISCSI_HASHMAP_KEY_ALIGN_SHIFT; uint64_t hash = ISCSI_HASHMAP_HASH_INITIAL; do { - hash ^= *(uint64_t *) data++; // Hash 8 bytes of data at once - hash *= ISCSI_HASHMAP_HASH_XOR; + hash ^= *hash_data++; + hash *= ISCSI_HASHMAP_HASH_MUL; } while ( --num_blocks > 0UL ); return (uint32_t) (hash ^ hash >> 32ULL); diff --git a/src/server/iscsi.h b/src/server/iscsi.h index 0f1419a..a8e0a35 100644 --- a/src/server/iscsi.h +++ b/src/server/iscsi.h @@ -111,8 +111,8 @@ static inline void iscsi_put_be64(uint8_t *data, const uint64_t val) #define ISCSI_HASHMAP_RESIZE_FACTOR 1UL // Number of bits to shift left when resizing #define ISCSI_HASHMAP_KEY_ALIGN_SHIFT 3UL // Key data shift value for alignment enforcement #define ISCSI_HASHMAP_KEY_ALIGN (1UL << (ISCSI_HASHMAP_KEY_ALIGN_SHIFT)) // Key data size must be multiple of 8 bytes by now -#define ISCSI_HASHMAP_HASH_INITIAL 2166136261UL // Initial hash code -#define ISCSI_HASHMAP_HASH_XOR 0xBF58476D1CE4E5B9ULL // XOR value for hash code +#define ISCSI_HASHMAP_HASH_INITIAL 0x811C9DC5UL // Initial hash code +#define ISCSI_HASHMAP_HASH_MUL 0xBF58476D1CE4E5B9ULL // Value to multiply hash code with typedef struct iscsi_hashmap_bucket { struct iscsi_hashmap_bucket *next; // Must be first element |
