Skip to content

Commit

Permalink
Vectorized fletcher_4 must be 64-bit aligned
Browse files Browse the repository at this point in the history
The fletcher_4_native() and fletcher_4_byteswap() functions may only
safely use the vectorized implementations when the buffer is 64-bit
aligned.  Otherwise fallback to the scalar implementation.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#4330
  • Loading branch information
behlendorf committed Jun 28, 2016
1 parent d1d19c7 commit 222ef5b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions module/zcommon/zfs_fletcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,12 @@ fletcher_4_impl_get(void)
void
fletcher_4_native(const void *buf, uint64_t size, zio_cksum_t *zcp)
{
const fletcher_4_ops_t *ops = fletcher_4_impl_get();
const fletcher_4_ops_t *ops;

if (IS_P2ALIGNED(size, sizeof (uint64_t)))
ops = fletcher_4_impl_get();
else
ops = &fletcher_4_scalar_ops;

ops->init(zcp);
ops->compute(buf, size, zcp);
Expand All @@ -345,7 +350,12 @@ fletcher_4_native(const void *buf, uint64_t size, zio_cksum_t *zcp)
void
fletcher_4_byteswap(const void *buf, uint64_t size, zio_cksum_t *zcp)
{
const fletcher_4_ops_t *ops = fletcher_4_impl_get();
const fletcher_4_ops_t *ops;

if (IS_P2ALIGNED(size, sizeof (uint64_t)))
ops = fletcher_4_impl_get();
else
ops = &fletcher_4_scalar_ops;

ops->init(zcp);
ops->compute_byteswap(buf, size, zcp);
Expand Down

0 comments on commit 222ef5b

Please sign in to comment.