Bug 194071 - zfsloader broken on sparc64 since r268649
Summary: zfsloader broken on sparc64 since r268649
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 10.1-BETA3
Hardware: sparc64 Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-01 14:14 UTC by Kurt Lidl
Modified: 2014-10-02 17:56 UTC (History)
3 users (show)

See Also:


Attachments
patch to sys/cddl/boot/zfs/lz4.c that fixes the problem (679 bytes, patch)
2014-10-01 14:15 UTC, Kurt Lidl
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kurt Lidl freebsd_committer freebsd_triage 2014-10-01 14:14:25 UTC
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
Comment 1 Kurt Lidl freebsd_committer freebsd_triage 2014-10-01 14:15:16 UTC
Created attachment 147885 [details]
patch to sys/cddl/boot/zfs/lz4.c that fixes the problem
Comment 2 Glen Barber freebsd_committer freebsd_triage 2014-10-01 14:20:24 UTC
Xin, could you take a look at this?
Comment 3 Xin LI freebsd_committer freebsd_triage 2014-10-01 18:02:03 UTC
Hi,

Do we need the same treatment on the ZFS copy of lz4.c?  (sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c)?
Comment 4 Kurt Lidl freebsd_committer freebsd_triage 2014-10-01 19:21:28 UTC
(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.
Comment 5 Xin LI freebsd_committer freebsd_triage 2014-10-02 00:13:50 UTC
(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.
Comment 6 commit-hook freebsd_committer freebsd_triage 2014-10-02 00:14:00 UTC
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
Comment 7 Kurt Lidl freebsd_committer freebsd_triage 2014-10-02 14:50:40 UTC
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.
Comment 8 commit-hook freebsd_committer freebsd_triage 2014-10-02 17:42:18 UTC
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
Comment 9 commit-hook freebsd_committer freebsd_triage 2014-10-02 17:42:19 UTC
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
Comment 10 commit-hook freebsd_committer freebsd_triage 2014-10-02 17:43:20 UTC
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
Comment 11 Xin LI freebsd_committer freebsd_triage 2014-10-02 17:55:32 UTC
Thanks for reporting and testing.  I have merged the change to all supported branches.
Comment 12 Kurt Lidl freebsd_committer freebsd_triage 2014-10-02 17:56:47 UTC
Thanks!