diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/icp/algs/sha2/sha2.c | 19 | ||||
-rw-r--r-- | module/icp/os/modhash.c | 2 | ||||
-rw-r--r-- | module/zcommon/Makefile.in | 13 | ||||
-rw-r--r-- | module/zcommon/zfeature_common.c (renamed from module/zfs/zfeature_common.c) | 9 | ||||
-rw-r--r-- | module/zcommon/zfs_comutil.c | 75 | ||||
-rw-r--r-- | module/zcommon/zfs_deleg.c | 2 | ||||
-rw-r--r-- | module/zcommon/zfs_fletcher.c | 9 | ||||
-rw-r--r-- | module/zfs/Makefile.in | 2 | ||||
-rw-r--r-- | module/zfs/zfs_ratelimit.c | 99 |
9 files changed, 133 insertions, 97 deletions
diff --git a/module/icp/algs/sha2/sha2.c b/module/icp/algs/sha2/sha2.c index dbe008190..c585993f1 100644 --- a/module/icp/algs/sha2/sha2.c +++ b/module/icp/algs/sha2/sha2.c @@ -52,7 +52,7 @@ static void Encode(uint8_t *, uint32_t *, size_t); static void Encode64(uint8_t *, uint64_t *, size_t); -#if defined(__amd64) +#if defined(__amd64) && defined(_KERNEL) #define SHA512Transform(ctx, in) SHA512TransformBlocks((ctx), (in), 1) #define SHA256Transform(ctx, in) SHA256TransformBlocks((ctx), (in), 1) @@ -62,7 +62,7 @@ void SHA256TransformBlocks(SHA2_CTX *ctx, const void *in, size_t num); #else static void SHA256Transform(SHA2_CTX *, const uint8_t *); static void SHA512Transform(SHA2_CTX *, const uint8_t *); -#endif /* __amd64 */ +#endif /* __amd64 && _KERNEL */ static uint8_t PADDING[128] = { 0x80, /* all zeros */ }; @@ -142,7 +142,7 @@ static uint8_t PADDING[128] = { 0x80, /* all zeros */ }; #endif /* _BIG_ENDIAN */ -#if !defined(__amd64) +#if !defined(__amd64) || !defined(_KERNEL) /* SHA256 Transform */ static void @@ -600,7 +600,7 @@ SHA512Transform(SHA2_CTX *ctx, const uint8_t *blk) ctx->state.s64[7] += h; } -#endif /* !__amd64 */ +#endif /* !__amd64 || !_KERNEL */ /* @@ -783,10 +783,6 @@ SHA2Update(SHA2_CTX *ctx, const void *inptr, size_t input_len) uint32_t i, buf_index, buf_len, buf_limit; const uint8_t *input = inptr; uint32_t algotype = ctx->algotype; -#if defined(__amd64) - uint32_t block_count; -#endif /* !__amd64 */ - /* check for noop */ if (input_len == 0) @@ -842,7 +838,7 @@ SHA2Update(SHA2_CTX *ctx, const void *inptr, size_t input_len) i = buf_len; } -#if !defined(__amd64) +#if !defined(__amd64) || !defined(_KERNEL) if (algotype <= SHA256_HMAC_GEN_MECH_INFO_TYPE) { for (; i + buf_limit - 1 < input_len; i += buf_limit) { SHA256Transform(ctx, &input[i]); @@ -854,6 +850,7 @@ SHA2Update(SHA2_CTX *ctx, const void *inptr, size_t input_len) } #else + uint32_t block_count; if (algotype <= SHA256_HMAC_GEN_MECH_INFO_TYPE) { block_count = (input_len - i) >> 6; if (block_count > 0) { @@ -869,7 +866,7 @@ SHA2Update(SHA2_CTX *ctx, const void *inptr, size_t input_len) i += block_count << 7; } } -#endif /* !__amd64 */ +#endif /* !__amd64 || !_KERNEL */ /* * general optimization: @@ -951,8 +948,6 @@ SHA2Final(void *digest, SHA2_CTX *ctx) bzero(ctx, sizeof (*ctx)); } - - #ifdef _KERNEL EXPORT_SYMBOL(SHA2Init); EXPORT_SYMBOL(SHA2Update); diff --git a/module/icp/os/modhash.c b/module/icp/os/modhash.c index 1ff782afc..497e84396 100644 --- a/module/icp/os/modhash.c +++ b/module/icp/os/modhash.c @@ -312,7 +312,7 @@ mod_hash_create_ptrhash(char *name, size_t nchains, * The high bits, which are also unused, will get taken out when * mod_hash takes hashkey % nchains. */ - rshift = highbit(key_elem_size); + rshift = highbit64(key_elem_size); return mod_hash_create_extended(name, nchains, mod_hash_null_keydtor, val_dtor, mod_hash_byptr, (void *)rshift, mod_hash_ptrkey_cmp, diff --git a/module/zcommon/Makefile.in b/module/zcommon/Makefile.in index 74bb4378e..86eb8ad39 100644 --- a/module/zcommon/Makefile.in +++ b/module/zcommon/Makefile.in @@ -7,16 +7,17 @@ EXTRA_CFLAGS = $(ZFS_MODULE_CFLAGS) @KERNELCPPFLAGS@ obj-$(CONFIG_ZFS) := $(MODULE).o -$(MODULE)-objs += zfs_deleg.o -$(MODULE)-objs += zfs_prop.o -$(MODULE)-objs += zprop_common.o -$(MODULE)-objs += zfs_namecheck.o +$(MODULE)-objs += zfeature_common.o $(MODULE)-objs += zfs_comutil.o +$(MODULE)-objs += zfs_deleg.o $(MODULE)-objs += zfs_fletcher.o -$(MODULE)-objs += zfs_uio.o -$(MODULE)-objs += zpool_prop.o $(MODULE)-objs += zfs_fletcher_superscalar.o $(MODULE)-objs += zfs_fletcher_superscalar4.o +$(MODULE)-objs += zfs_namecheck.o +$(MODULE)-objs += zfs_prop.o +$(MODULE)-objs += zfs_uio.o +$(MODULE)-objs += zpool_prop.o +$(MODULE)-objs += zprop_common.o $(MODULE)-$(CONFIG_X86) += zfs_fletcher_intel.o $(MODULE)-$(CONFIG_X86) += zfs_fletcher_sse.o diff --git a/module/zfs/zfeature_common.c b/module/zcommon/zfeature_common.c index 73abcb236..321ee04bf 100644 --- a/module/zfs/zfeature_common.c +++ b/module/zcommon/zfeature_common.c @@ -319,3 +319,12 @@ zpool_feature_init(void) userobj_accounting_deps); } } + +#if defined(_KERNEL) && defined(HAVE_SPL) +EXPORT_SYMBOL(zfeature_lookup_name); +EXPORT_SYMBOL(zfeature_is_supported); +EXPORT_SYMBOL(zfeature_is_valid_guid); +EXPORT_SYMBOL(zfeature_depends_on); +EXPORT_SYMBOL(zpool_feature_init); +EXPORT_SYMBOL(spa_feature_table); +#endif diff --git a/module/zcommon/zfs_comutil.c b/module/zcommon/zfs_comutil.c index 52cb7e365..685a20c44 100644 --- a/module/zcommon/zfs_comutil.c +++ b/module/zcommon/zfs_comutil.c @@ -207,85 +207,10 @@ const char *zfs_history_event_names[ZFS_NUM_LEGACY_HISTORY_EVENTS] = { "pool split", }; -/* - * Initialize rate limit struct - * - * rl: zfs_ratelimit_t struct - * burst: Number to allow in an interval before rate limiting - * interval: Interval time in seconds - */ -void -zfs_ratelimit_init(zfs_ratelimit_t *rl, unsigned int burst, - unsigned int interval) -{ - rl->count = 0; - rl->start = 0; - rl->interval = interval; - rl->burst = burst; - mutex_init(&rl->lock, NULL, MUTEX_DEFAULT, NULL); -} - -/* - * Finalize rate limit struct - * - * rl: zfs_ratelimit_t struct - */ -void -zfs_ratelimit_fini(zfs_ratelimit_t *rl) -{ - mutex_destroy(&rl->lock); -} - -/* - * Re-implementation of the kernel's __ratelimit() function - * - * We had to write our own rate limiter because the kernel's __ratelimit() - * function annoyingly prints out how many times it rate limited to the kernel - * logs (and there's no way to turn it off): - * - * __ratelimit: 59 callbacks suppressed - * - * If the kernel ever allows us to disable these prints, we should go back to - * using __ratelimit() instead. - * - * Return values are the same as __ratelimit(): - * - * 0: If we're rate limiting - * 1: If we're not rate limiting. - */ -int -zfs_ratelimit(zfs_ratelimit_t *rl) -{ - hrtime_t now; - hrtime_t elapsed; - int rc = 1; - - mutex_enter(&rl->lock); - - now = gethrtime(); - elapsed = now - rl->start; - - rl->count++; - if (NSEC2SEC(elapsed) >= rl->interval) { - rl->start = now; - rl->count = 0; - } else { - if (rl->count >= rl->burst) { - rc = 0; /* We're ratelimiting */ - } - } - mutex_exit(&rl->lock); - - return (rc); -} - #if defined(_KERNEL) && defined(HAVE_SPL) EXPORT_SYMBOL(zfs_allocatable_devs); EXPORT_SYMBOL(zpool_get_rewind_policy); EXPORT_SYMBOL(zfs_zpl_version_map); EXPORT_SYMBOL(zfs_spa_version_map); EXPORT_SYMBOL(zfs_history_event_names); -EXPORT_SYMBOL(zfs_ratelimit_init); -EXPORT_SYMBOL(zfs_ratelimit_fini); -EXPORT_SYMBOL(zfs_ratelimit); #endif diff --git a/module/zcommon/zfs_deleg.c b/module/zcommon/zfs_deleg.c index ce659d7f5..90e9048b1 100644 --- a/module/zcommon/zfs_deleg.c +++ b/module/zcommon/zfs_deleg.c @@ -233,7 +233,7 @@ zfs_deleg_whokey(char *attr, zfs_deleg_who_type_t type, ZFS_DELEG_FIELD_SEP_CHR); break; default: - cmn_err(CE_PANIC, "bad zfs_deleg_who_type_t %d", type); + ASSERT(!"bad zfs_deleg_who_type_t"); } } diff --git a/module/zcommon/zfs_fletcher.c b/module/zcommon/zfs_fletcher.c index 9cdf36d44..0cd992979 100644 --- a/module/zcommon/zfs_fletcher.c +++ b/module/zcommon/zfs_fletcher.c @@ -212,7 +212,9 @@ static struct fletcher_4_impl_selector { { "scalar", IMPL_SCALAR } }; +#if defined(_KERNEL) static kstat_t *fletcher_4_kstat; +#endif static struct fletcher_4_kstat { uint64_t native; @@ -589,7 +591,7 @@ fletcher_4_incremental_byteswap(void *buf, size_t size, void *data) return (0); } - +#if defined(_KERNEL) /* Fletcher 4 kstats */ static int @@ -642,6 +644,7 @@ fletcher_4_kstat_addr(kstat_t *ksp, loff_t n) return (ksp->ks_private); } +#endif #define FLETCHER_4_FASTEST_FN_COPY(type, src) \ { \ @@ -753,6 +756,7 @@ fletcher_4_init(void) vmem_free(databuf, data_size); +#if defined(_KERNEL) /* install kstats for all implementations */ fletcher_4_kstat = kstat_create("zfs", 0, "fletcher_4_bench", "misc", KSTAT_TYPE_RAW, 0, KSTAT_FLAG_VIRTUAL); @@ -765,6 +769,7 @@ fletcher_4_init(void) fletcher_4_kstat_addr); kstat_install(fletcher_4_kstat); } +#endif /* Finish initialization */ fletcher_4_initialized = B_TRUE; @@ -773,10 +778,12 @@ fletcher_4_init(void) void fletcher_4_fini(void) { +#if defined(_KERNEL) if (fletcher_4_kstat != NULL) { kstat_delete(fletcher_4_kstat); fletcher_4_kstat = NULL; } +#endif } /* ABD adapters */ diff --git a/module/zfs/Makefile.in b/module/zfs/Makefile.in index d6336f314..b849d9010 100644 --- a/module/zfs/Makefile.in +++ b/module/zfs/Makefile.in @@ -82,7 +82,6 @@ $(MODULE)-objs += zap.o $(MODULE)-objs += zap_leaf.o $(MODULE)-objs += zap_micro.o $(MODULE)-objs += zfeature.o -$(MODULE)-objs += zfeature_common.o $(MODULE)-objs += zfs_acl.o $(MODULE)-objs += zfs_byteswap.o $(MODULE)-objs += zfs_ctldir.o @@ -93,6 +92,7 @@ $(MODULE)-objs += zfs_fuid.o $(MODULE)-objs += zfs_ioctl.o $(MODULE)-objs += zfs_log.o $(MODULE)-objs += zfs_onexit.o +$(MODULE)-objs += zfs_ratelimit.o $(MODULE)-objs += zfs_replay.o $(MODULE)-objs += zfs_rlock.o $(MODULE)-objs += zfs_sa.o diff --git a/module/zfs/zfs_ratelimit.c b/module/zfs/zfs_ratelimit.c new file mode 100644 index 000000000..d4a7d5217 --- /dev/null +++ b/module/zfs/zfs_ratelimit.c @@ -0,0 +1,99 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2017, Lawrence Livermore National Security, LLC. + */ + +#include <sys/zfs_ratelimit.h> + +/* + * Initialize rate limit struct + * + * rl: zfs_ratelimit_t struct + * burst: Number to allow in an interval before rate limiting + * interval: Interval time in seconds + */ +void +zfs_ratelimit_init(zfs_ratelimit_t *rl, unsigned int burst, + unsigned int interval) +{ + rl->count = 0; + rl->start = 0; + rl->interval = interval; + rl->burst = burst; + mutex_init(&rl->lock, NULL, MUTEX_DEFAULT, NULL); +} + +/* + * Finalize rate limit struct + * + * rl: zfs_ratelimit_t struct + */ +void +zfs_ratelimit_fini(zfs_ratelimit_t *rl) +{ + mutex_destroy(&rl->lock); +} + +/* + * Re-implementation of the kernel's __ratelimit() function + * + * We had to write our own rate limiter because the kernel's __ratelimit() + * function annoyingly prints out how many times it rate limited to the kernel + * logs (and there's no way to turn it off): + * + * __ratelimit: 59 callbacks suppressed + * + * If the kernel ever allows us to disable these prints, we should go back to + * using __ratelimit() instead. + * + * Return values are the same as __ratelimit(): + * + * 0: If we're rate limiting + * 1: If we're not rate limiting. + */ +int +zfs_ratelimit(zfs_ratelimit_t *rl) +{ + hrtime_t now; + + hrtime_t elapsed; + int error = 1; + + mutex_enter(&rl->lock); + + now = gethrtime(); + elapsed = now - rl->start; + + rl->count++; + if (NSEC2SEC(elapsed) >= rl->interval) { + rl->start = now; + rl->count = 0; + } else { + if (rl->count >= rl->burst) { + error = 0; /* We're ratelimiting */ + } + } + mutex_exit(&rl->lock); + + return (error); +} |