From 3f38797338f2e4b16e8e0065e21f1bca6ef59784 Mon Sep 17 00:00:00 2001 From: Matthew Ahrens Date: Fri, 27 Mar 2020 09:11:22 -0700 Subject: [PATCH] Compile cityhash code into libzfs Make the cityhash code compile into libzfs, in preparation for the new "zstream" command. Reviewed-by: Paul Dagnelie Reviewed-by: Brian Behlendorf Signed-off-by: Matthew Ahrens Closes #10152 --- include/Makefile.am | 1 + include/{sys => }/cityhash.h | 0 include/sys/Makefile.am | 1 - lib/libzfs/Makefile.am | 1 + module/zcommon/Makefile.in | 1 + module/{zfs => zcommon}/cityhash.c | 6 +++++- module/zfs/Makefile.in | 1 - module/zfs/arc.c | 2 +- module/zfs/dbuf.c | 2 +- module/zfs/zio.c | 2 +- 10 files changed, 11 insertions(+), 6 deletions(-) rename include/{sys => }/cityhash.h (100%) rename module/{zfs => zcommon}/cityhash.c (96%) diff --git a/include/Makefile.am b/include/Makefile.am index 5b37dc765d26..9591d44239dd 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,6 +1,7 @@ SUBDIRS = sys os COMMON_H = \ + $(top_srcdir)/include/cityhash.h \ $(top_srcdir)/include/zfeature_common.h \ $(top_srcdir)/include/zfs_comutil.h \ $(top_srcdir)/include/zfs_deleg.h \ diff --git a/include/sys/cityhash.h b/include/cityhash.h similarity index 100% rename from include/sys/cityhash.h rename to include/cityhash.h diff --git a/include/sys/Makefile.am b/include/sys/Makefile.am index bcfa12fca4b2..82165170a386 100644 --- a/include/sys/Makefile.am +++ b/include/sys/Makefile.am @@ -14,7 +14,6 @@ COMMON_H = \ $(top_srcdir)/include/sys/bptree.h \ $(top_srcdir)/include/sys/btree.h \ $(top_srcdir)/include/sys/bqueue.h \ - $(top_srcdir)/include/sys/cityhash.h \ $(top_srcdir)/include/sys/dataset_kstats.h \ $(top_srcdir)/include/sys/dbuf.h \ $(top_srcdir)/include/sys/ddt.h \ diff --git a/lib/libzfs/Makefile.am b/lib/libzfs/Makefile.am index da42307bb6fb..2747a7e9b3e3 100644 --- a/lib/libzfs/Makefile.am +++ b/lib/libzfs/Makefile.am @@ -38,6 +38,7 @@ endif KERNEL_C = \ algs/sha2/sha2.c \ + cityhash.c \ zfeature_common.c \ zfs_comutil.c \ zfs_deleg.c \ diff --git a/module/zcommon/Makefile.in b/module/zcommon/Makefile.in index b2e34f2e9339..01e0692ebddf 100644 --- a/module/zcommon/Makefile.in +++ b/module/zcommon/Makefile.in @@ -11,6 +11,7 @@ ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS) # Suppress unused-value warnings in sparc64 architecture headers ccflags-$(CONFIG_SPARC64) += -Wno-unused-value +$(MODULE)-objs += cityhash.o $(MODULE)-objs += zfeature_common.o $(MODULE)-objs += zfs_comutil.o $(MODULE)-objs += zfs_deleg.o diff --git a/module/zfs/cityhash.c b/module/zcommon/cityhash.c similarity index 96% rename from module/zfs/cityhash.c rename to module/zcommon/cityhash.c index 2b62edad0342..413a96df2cda 100644 --- a/module/zfs/cityhash.c +++ b/module/zcommon/cityhash.c @@ -22,7 +22,7 @@ * Copyright (c) 2017 by Delphix. All rights reserved. */ -#include +#include #define HASH_K1 0xb492b66fbe98f273ULL #define HASH_K2 0x9ae16a3b2f90404fULL @@ -61,3 +61,7 @@ cityhash4(uint64_t w1, uint64_t w2, uint64_t w3, uint64_t w4) a + rotate(b + HASH_K2, 18) + c, mul)); } + +#if defined(_KERNEL) +EXPORT_SYMBOL(cityhash4); +#endif diff --git a/module/zfs/Makefile.in b/module/zfs/Makefile.in index 1ba7db27b96e..6737336caef9 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 6c9164f76bcb..c6b194183f2e 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -299,7 +299,7 @@ #include #include #include -#include +#include #ifndef _KERNEL /* set with ZFS_DEBUG=watch, to enable watchpoints on frozen buffers */ diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c index d7f5e1ee32ec..be6a76830af3 100644 --- a/module/zfs/dbuf.c +++ b/module/zfs/dbuf.c @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include kstat_t *dbuf_ksp; diff --git a/module/zfs/zio.c b/module/zfs/zio.c index de2e8e767200..b9a3ddcf237e 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -47,7 +47,7 @@ #include #include #include -#include +#include /* * ==========================================================================