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 <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Closes #14785
Closes #14808
This commit is contained in:
Mateusz Guzik 2023-05-02 02:21:27 +02:00 committed by GitHub
parent 0c93d86f01
commit e2a92d726e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,7 +50,8 @@ abd_checksum_blake3_native(abd_t *abd, uint64_t size, const void *ctx_template,
ASSERT(ctx_template != NULL); ASSERT(ctx_template != NULL);
#if defined(_KERNEL) #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 #else
BLAKE3_CTX *ctx = kmem_alloc(sizeof (*ctx), KM_SLEEP); BLAKE3_CTX *ctx = kmem_alloc(sizeof (*ctx), KM_SLEEP);
#endif #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); (void) abd_iterate_func(abd, 0, size, blake3_incremental, ctx);
Blake3_Final(ctx, (uint8_t *)zcp); Blake3_Final(ctx, (uint8_t *)zcp);
#if !defined(_KERNEL) #if defined(_KERNEL)
kpreempt_enable();
#else
memset(ctx, 0, sizeof (*ctx)); memset(ctx, 0, sizeof (*ctx));
kmem_free(ctx, sizeof (*ctx)); kmem_free(ctx, sizeof (*ctx));
#endif #endif