]> git.proxmox.com Git - mirror_zfs.git/commit
Fix assertions in crypto reference helpers
authorRichard Yao <richard.yao@alumni.stonybrook.edu>
Thu, 15 Sep 2022 20:24:00 +0000 (16:24 -0400)
committerGitHub <noreply@github.com>
Thu, 15 Sep 2022 20:24:00 +0000 (13:24 -0700)
commite949d36040e5e79fe0dfda6a33451111cc5a0476
tree35aa4b33d1729688326a461ba5d96e0d8964f35c
parentdc2fe24ca22392a589fbafdf15e4c32f42442006
Fix assertions in crypto reference helpers

The assertions are racy and the use of `membar_exit()` did nothing to
fix that.

The helpers use atomic functions, so we cleverly get values from the
atomics that we can use to ensure that the assertions operate on the
correct values.

We also use `membar_producer()` prior to decrementing reference counts
so that operations that happened prior to a decrement to 0 will be
guaranteed to happen before the decrement on architectures that reorder
atomics.

This also slightly improves performance by eliminating unnecessary
reads, although I doubt it would be measurable in any benchmark.

Reviewed-by: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13880
module/icp/include/sys/crypto/impl.h
module/icp/include/sys/crypto/sched_impl.h