From 2eee4ac1eabcb70f474f5267031c43511ad977ea Mon Sep 17 00:00:00 2001 From: Pranav P <49746983+pranavkaruvally@users.noreply.github.com> Date: Wed, 22 Apr 2026 22:23:48 +0530 Subject: [PATCH] Fix: draid autopkgtests fail on s390x architecture (Endianness Issue) The ioctl call to create the pool was returning -1 with errno EINVAL. Inside the module code, inside vdev_draid.c, verify_perms is calling fletcher_4_native_varsize. This in turn calls fletcher_4_scalar_native. So, implemented a fletcher_4_byteswap_varsize which makes use of the fletcher_4_scalar_byteswap in Big endian machines. Reviewed-by: Andriy Tkachuk Reviewed-by: Brian Behlendorf Signed-off-by: Pranav P Closes #16261 Closes #18445 --- include/zfs_fletcher.h | 2 + lib/libzfs/libzfs.abi | 144 ++++++++++++++++++++++++++++++++-- module/zcommon/zfs_fletcher.c | 7 ++ module/zfs/vdev_draid.c | 4 + 4 files changed, 150 insertions(+), 7 deletions(-) diff --git a/include/zfs_fletcher.h b/include/zfs_fletcher.h index d450f7f5e8a..4cd8cabfab9 100644 --- a/include/zfs_fletcher.h +++ b/include/zfs_fletcher.h @@ -60,6 +60,8 @@ _ZFS_FLETCHER_H int fletcher_2_incremental_native(void *, size_t, void *); _ZFS_FLETCHER_H int fletcher_2_incremental_byteswap(void *, size_t, void *); _ZFS_FLETCHER_H void fletcher_4_native_varsize(const void *, uint64_t, zio_cksum_t *); +_ZFS_FLETCHER_H void fletcher_4_byteswap_varsize(const void *, uint64_t, + zio_cksum_t *); _ZFS_FLETCHER_H void fletcher_4_byteswap(const void *, uint64_t, const void *, zio_cksum_t *); _ZFS_FLETCHER_H int fletcher_4_incremental_native(void *, size_t, void *); diff --git a/lib/libzfs/libzfs.abi b/lib/libzfs/libzfs.abi index 6349fca09bc..ad28c876630 100644 --- a/lib/libzfs/libzfs.abi +++ b/lib/libzfs/libzfs.abi @@ -189,6 +189,7 @@ + @@ -1668,8 +1669,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1681,6 +1777,14 @@ + + + + + + + + @@ -3830,6 +3934,10 @@ + + + + @@ -3854,9 +3962,6 @@ - - - @@ -4529,10 +4634,6 @@ - - - - @@ -4642,6 +4743,9 @@ + + + @@ -4909,6 +5013,12 @@ + + + + + + @@ -5155,6 +5265,19 @@ + + + + + + + + + + + + + @@ -8337,6 +8460,7 @@ + @@ -10331,6 +10455,12 @@ + + + + + + diff --git a/module/zcommon/zfs_fletcher.c b/module/zcommon/zfs_fletcher.c index 1a7dde1dd8f..5f6f37157ff 100644 --- a/module/zcommon/zfs_fletcher.c +++ b/module/zcommon/zfs_fletcher.c @@ -499,6 +499,13 @@ fletcher_4_native_varsize(const void *buf, uint64_t size, zio_cksum_t *zcp) fletcher_4_scalar_native((fletcher_4_ctx_t *)zcp, buf, size); } +void +fletcher_4_byteswap_varsize(const void *buf, uint64_t size, zio_cksum_t *zcp) +{ + ZIO_SET_CHECKSUM(zcp, 0, 0, 0, 0); + fletcher_4_scalar_byteswap((fletcher_4_ctx_t *)zcp, buf, size); +} + static inline void fletcher_4_byteswap_impl(const void *buf, uint64_t size, zio_cksum_t *zcp) { diff --git a/module/zfs/vdev_draid.c b/module/zfs/vdev_draid.c index c76557e80c9..8f556b86878 100644 --- a/module/zfs/vdev_draid.c +++ b/module/zfs/vdev_draid.c @@ -505,7 +505,11 @@ verify_perms(uint8_t *perms, uint64_t children, uint64_t nperms, int permssz = sizeof (uint8_t) * children * nperms; zio_cksum_t cksum; +#if defined(_ZFS_BIG_ENDIAN) + fletcher_4_byteswap_varsize(perms, permssz, &cksum); +#else fletcher_4_native_varsize(perms, permssz, &cksum); +#endif if (checksum != cksum.zc_word[0]) { kmem_free(counts, countssz);