It took a while to track this down, but the zfsloader on sparc64 machines has been broken since r268649. That's when the lz4 compression was added to ZFS. This affects 10.1-BETA2 and 10.1-BETA3, where I did my diagnostic work. I'm sure that it also affects head. In a nutshell, the lz4 code is missing a couple of portability fixes that allow for unaligned access to some of the data structures in a compressed lz4 data stream. When attempting to boot off a zfsloader with this problem, one will see errors similar to this: >> FreeBSD/sparc64 ZFS boot block Boot path: /pci@1f,0/pci@1/scsi@8/disk@0,0:a Consoles: Open Firmware console ^M Memory Address not Aligned After bisecting the stable/10 tree over the last couple of nights, I figured out the exact revision where it failed. (r268649) Looking at the lz4 project's sources, it appears there was a portability fix introduced in this patchset: https://code.google.com/p/lz4/source/detail?r=95 In particular, the patch that is needed for sparc64 is addition of a __attribute__((packed)) to some of the data structures for the lz4 implementation. I've reduced this to use the FreeBSD __packed definition that is in <sys/cdefs.h>. With the attached patch, recompiling stable/10 on a sparc64, I get a useable zfsloader, so I can once again boot a zfs-only sparc64 machine. Please include this patch (or equivalent) in HEAD and in the 10.1 release. This will avoid a major regression in ZFS booting between 10.0 and 10.1 releases. Thanks. -Kurt
Created attachment 147885 [details] patch to sys/cddl/boot/zfs/lz4.c that fixes the problem
Xin, could you take a look at this?
Hi, Do we need the same treatment on the ZFS copy of lz4.c? (sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c)?
(In reply to Xin LI from comment #3) > Do we need the same treatment on the ZFS copy of lz4.c? > (sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c)? That code has wrapped with: #ifndef LZ4_FORCE_UNALIGNED_ACCESS #pragma pack(1) #endif <code> #ifndef LZ4_FORCE_UNALIGNED_ACCESS #pragma pack() #endif So it has already been treated in the same manner.
(In reply to lidl from comment #4) > (In reply to Xin LI from comment #3) > > Do we need the same treatment on the ZFS copy of lz4.c? > > (sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c)? > > That code has wrapped with: > > #ifndef LZ4_FORCE_UNALIGNED_ACCESS > #pragma pack(1) > #endif > > <code> > > #ifndef LZ4_FORCE_UNALIGNED_ACCESS > #pragma pack() > #endif > > So it has already been treated in the same manner. Can you try r272389 and let me know if it fixed your problem? If everything works fine I'd like to merge this as soon as possible.
A commit references this bug: Author: delphij Date: Thu Oct 2 00:13:09 UTC 2014 New revision: 272389 URL: https://svnweb.freebsd.org/changeset/base/272389 Log: Diff reduction with kernel code: instruct the compiler that the data of these types may be unaligned to their "normal" alignment and exercise caution when accessing them. PR: 194071 MFC after: 3 days Changes: head/sys/cddl/boot/zfs/lz4.c
I had my sparc grind through a partial buildworld of r272389. I was able to get the zfsloader built, and it worked fine to load the 10.1-BETA3 system that I had installed earlier. The patch resolves the issue with zfsloader. I really hope this can be included in the 10.1-RELEASE image.
A commit references this bug: Author: delphij Date: Thu Oct 2 17:41:28 UTC 2014 New revision: 272425 URL: https://svnweb.freebsd.org/changeset/base/272425 Log: MFC r272389: Diff reduction with kernel code: instruct the compiler that the data of these types may be unaligned to their "normal" alignment and exercise caution when accessing them. PR: 194071 Approved by: re (gjb) Changes: _U stable/10/ stable/10/sys/cddl/boot/zfs/lz4.c
A commit references this bug: Author: delphij Date: Thu Oct 2 17:42:03 UTC 2014 New revision: 272426 URL: https://svnweb.freebsd.org/changeset/base/272426 Log: MFC r272389: Diff reduction with kernel code: instruct the compiler that the data of these types may be unaligned to their "normal" alignment and exercise caution when accessing them. PR: 194071 Changes: _U stable/9/sys/ stable/9/sys/cddl/boot/zfs/lz4.c
A commit references this bug: Author: delphij Date: Thu Oct 2 17:42:21 UTC 2014 New revision: 272427 URL: https://svnweb.freebsd.org/changeset/base/272427 Log: MFC r272389: Diff reduction with kernel code: instruct the compiler that the data of these types may be unaligned to their "normal" alignment and exercise caution when accessing them. PR: 194071 Changes: _U stable/8/sys/ _U stable/8/sys/cddl/ stable/8/sys/cddl/boot/zfs/lz4.c
Thanks for reporting and testing. I have merged the change to all supported branches.
Thanks!