diff options
author | Matthew Ahrens <[email protected]> | 2020-03-27 09:11:22 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-27 09:11:22 -0700 |
commit | 3f38797338f2e4b16e8e0065e21f1bca6ef59784 (patch) | |
tree | f4f5f48791c5961bb1b8896b66e535020375e973 /module/zfs | |
parent | ef3331e703a8fa988bc09129f6f8d8f7c4c4082f (diff) |
Compile cityhash code into libzfs
Make the cityhash code compile into libzfs, in preparation for the new
"zstream" command.
Reviewed-by: Paul Dagnelie <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Matthew Ahrens <[email protected]>
Closes #10152
Diffstat (limited to 'module/zfs')
-rw-r--r-- | module/zfs/Makefile.in | 1 | ||||
-rw-r--r-- | module/zfs/arc.c | 2 | ||||
-rw-r--r-- | module/zfs/cityhash.c | 63 | ||||
-rw-r--r-- | module/zfs/dbuf.c | 2 | ||||
-rw-r--r-- | module/zfs/zio.c | 2 |
5 files changed, 3 insertions, 67 deletions
diff --git a/module/zfs/Makefile.in b/module/zfs/Makefile.in index 1ba7db27b..6737336ca 100644 --- a/module/zfs/Makefile.in +++ b/module/zfs/Makefile.in @@ -22,7 +22,6 @@ $(MODULE)-objs += bpobj.o $(MODULE)-objs += bptree.o $(MODULE)-objs += btree.o $(MODULE)-objs += bqueue.o -$(MODULE)-objs += cityhash.o $(MODULE)-objs += dataset_kstats.o $(MODULE)-objs += dbuf.o $(MODULE)-objs += dbuf_stats.o diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 6c9164f76..c6b194183 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -299,7 +299,7 @@ #include <sys/arc_impl.h> #include <sys/trace_zfs.h> #include <sys/aggsum.h> -#include <sys/cityhash.h> +#include <cityhash.h> #ifndef _KERNEL /* set with ZFS_DEBUG=watch, to enable watchpoints on frozen buffers */ diff --git a/module/zfs/cityhash.c b/module/zfs/cityhash.c deleted file mode 100644 index 2b62edad0..000000000 --- a/module/zfs/cityhash.c +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2011 Google, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -/* - * Copyright (c) 2017 by Delphix. All rights reserved. - */ - -#include <sys/cityhash.h> - -#define HASH_K1 0xb492b66fbe98f273ULL -#define HASH_K2 0x9ae16a3b2f90404fULL - -/* - * Bitwise right rotate. Normally this will compile to a single - * instruction. - */ -static inline uint64_t -rotate(uint64_t val, int shift) -{ - // Avoid shifting by 64: doing so yields an undefined result. - return (shift == 0 ? val : (val >> shift) | (val << (64 - shift))); -} - -static inline uint64_t -cityhash_helper(uint64_t u, uint64_t v, uint64_t mul) -{ - uint64_t a = (u ^ v) * mul; - a ^= (a >> 47); - uint64_t b = (v ^ a) * mul; - b ^= (b >> 47); - b *= mul; - return (b); -} - -uint64_t -cityhash4(uint64_t w1, uint64_t w2, uint64_t w3, uint64_t w4) -{ - uint64_t mul = HASH_K2 + 64; - uint64_t a = w1 * HASH_K1; - uint64_t b = w2; - uint64_t c = w4 * mul; - uint64_t d = w3 * HASH_K2; - return (cityhash_helper(rotate(a + b, 43) + rotate(c, 30) + d, - a + rotate(b + HASH_K2, 18) + c, mul)); - -} diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c index d7f5e1ee3..be6a76830 100644 --- a/module/zfs/dbuf.c +++ b/module/zfs/dbuf.c @@ -48,7 +48,7 @@ #include <sys/callb.h> #include <sys/abd.h> #include <sys/vdev.h> -#include <sys/cityhash.h> +#include <cityhash.h> #include <sys/spa_impl.h> kstat_t *dbuf_ksp; diff --git a/module/zfs/zio.c b/module/zfs/zio.c index de2e8e767..b9a3ddcf2 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -47,7 +47,7 @@ #include <sys/trace_zfs.h> #include <sys/abd.h> #include <sys/dsl_crypt.h> -#include <sys/cityhash.h> +#include <cityhash.h> /* * ========================================================================== |