diff options
| author | Sebastian Vater | 2025-07-24 15:55:42 +0200 |
|---|---|---|
| committer | Sebastian Vater | 2025-07-24 15:55:42 +0200 |
| commit | 74b8ced1eee373ada8554ddbcb0e8a1bd8b7c574 (patch) | |
| tree | 95e841a3379dfc939f42da7b8c4392101088edef /src/server/iscsi.c | |
| parent | Fixed some typos and changed header digest CRC32C functions to store the resu... (diff) | |
| download | dnbd3-74b8ced1eee373ada8554ddbcb0e8a1bd8b7c574.tar.gz dnbd3-74b8ced1eee373ada8554ddbcb0e8a1bd8b7c574.tar.xz dnbd3-74b8ced1eee373ada8554ddbcb0e8a1bd8b7c574.zip | |
Made fast hashing a little bit more readable and fixed address increment for next hash data value (should be 8 bytes instead of 1).
Diffstat (limited to 'src/server/iscsi.c')
| -rw-r--r-- | src/server/iscsi.c | 5 |
1 files changed, 3 insertions, 2 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); |
