From e2a92d726e1849f646d137510796b11c26d45cae Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Tue, 2 May 2023 02:21:27 +0200 Subject: [PATCH] blake3: fix up bogus checksums in face of cpu migration This is a temporary measure until a better fix is sorted out. Reviewed-by: Richard Yao Reviewed-by: Alexander Motin Reviewed-by: Rich Ercolani Signed-off-by: Mateusz Guzik Sponsored by: Rubicon Communications, LLC ("Netgate") Closes #14785 Closes #14808 --- module/zfs/blake3_zfs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/module/zfs/blake3_zfs.c b/module/zfs/blake3_zfs.c index bcc595bca8..7783282b67 100644 --- a/module/zfs/blake3_zfs.c +++ b/module/zfs/blake3_zfs.c @@ -50,7 +50,8 @@ abd_checksum_blake3_native(abd_t *abd, uint64_t size, const void *ctx_template, ASSERT(ctx_template != NULL); #if defined(_KERNEL) - BLAKE3_CTX *ctx = blake3_per_cpu_ctx[CPU_SEQID_UNSTABLE]; + kpreempt_disable(); + BLAKE3_CTX *ctx = blake3_per_cpu_ctx[CPU_SEQID]; #else BLAKE3_CTX *ctx = kmem_alloc(sizeof (*ctx), KM_SLEEP); #endif @@ -59,7 +60,9 @@ abd_checksum_blake3_native(abd_t *abd, uint64_t size, const void *ctx_template, (void) abd_iterate_func(abd, 0, size, blake3_incremental, ctx); Blake3_Final(ctx, (uint8_t *)zcp); -#if !defined(_KERNEL) +#if defined(_KERNEL) + kpreempt_enable(); +#else memset(ctx, 0, sizeof (*ctx)); kmem_free(ctx, sizeof (*ctx)); #endif