openzfs / zfs

OpenZFS on Linux and FreeBSD
https://openzfs.github.io/openzfs-docs
Other
10.64k stars 1.75k forks source link

OpenZFS 2.3.0-rc3 & UCLIBC. Crash while compiling. MS_RDONLY = 1 #16735

Open jlsalvador opened 3 days ago

jlsalvador commented 3 days ago

Hi again,

I’m currently outside with very limited internet access and no computer, only a phone. Please excuse the brief explanation and lack of proper debugging.

The compilation crash for uClibc with OpenZFS 2.3.0-rc3 is as follows (note that it works correctly with glibc and musl):

In file included from tests/zfs-tests/cmd/getversion.c:22:
/tmp/tmp.s4lnjcKpqa/TestZfsUclibc/host/x86_64-buildroot-linux-uclibc/sysroot/usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
   35 |   MS_RDONLY = 1,                /* Mount read-only.  */
      |   ^~~~~~~~~
  CC       tests/zfs-tests/cmd/idmap_util.o
make[4]: *** [Makefile:8906: tests/zfs-tests/cmd/getversion.o] Error 1
make[4]: *** Waiting for unfinished jobs....                                  make[3]: *** [Makefile:12578: all-recursive] Error 1                          make[2]: *** [Makefile:4751: all] Error 2                                     make[1]: *** [package/pkg-generic.mk:289: /tmp/tmp.s4lnjcKpqa/TestZfsUclibc/build/zfs-2.3.0-rc3/.stamp_built] Error 2
make: *** [Makefile:23: _all] Error 2
E                                                                             ======================================================================
ERROR: test_run (tests.package.test_zfs.TestZfsUclibc.test_run)
----------------------------------------------------------------------        Traceback (most recent call last):                                              File "/home/jlsalvador/src/simplek8s-buildroot/buildroot/support/testing/infra/basetest.py", line 74, in setUp                                                self.b.build()                                                              File "/home/jlsalvador/src/simplek8s-buildroot/buildroot/support/testing/infra/builder.py", line 105, in build
    raise SystemError("Build failed")                                         SystemError: Build failed

----------------------------------------------------------------------        Ran 1 test in 471.419s                                                        
FAILED (errors=1)

System information

Type Version/Name
Distribution Name buildroot
Distribution Version main
Kernel Version 5.15.35
Architecture x86-64
OpenZFS Version 2.3.0-rc3

Describe the problem you're observing

Describe how to reproduce the problem

Include any warning/errors/backtraces from the system logs

jlsalvador commented 3 days ago

AFK for ~48h. I will debug it later.

robn commented 3 days ago

Just from proximity, I wonder if #15925 broke this? @thesamesam?

thesamesam commented 3 days ago

I'll take a look, thanks for the ping. I know what the class of problem is (unfortunate clashes with linux-headers vs libc headers), but the specifics need checking.

@jlsalvador Gentoo doesn't support uclibc anymore so it's not easy for me to quickly get an env setup. Do you have any recommendations for how I can?

jlsalvador commented 3 days ago

I'll take a look, thanks for the ping. I know what the class of problem is (unfortunate clashes with linux-headers vs libc headers), but the specifics need checking.

@jlsalvador Gentoo doesn't support uclibc anymore so it's not easy for me to quickly get an env setup. Do you have any recommendations for how I can?

git clone https://gitlab.com/buildroot.org/buildroot.git

cd buildroot

./support/testing/run-tests -d $(pwd)/dl -o $(mktemp -d) -s tests.package.test_zfs.TestZfsUclibc.test_run

patch to openzfs-2.3.0-rc3: https://gist.github.com/jlsalvador/9b6bd33a569c049438831f38b4054744

jlsalvador commented 2 days ago

Just from proximity, I wonder if #15925 broke this? @thesamesam?

It compiles when the commit e12d76176d4e5454db62eb48b58ecd4970838a76 is reverted.

jlsalvador commented 2 days ago

tests/zfs-tests/cmd/getversion.c needs as fallback:

#ifdef _KERNEL
#include <sys/fcntl.h>
#else
#include <fcntl.h>
#endif
thesamesam commented 2 days ago

Thanks, that LGTM (and it's the issue I thought I'd seen in that PR but then couldn't reproduce at all later). Want to submit it or should I?

jlsalvador commented 2 days ago

Thanks, that LGTM (and it's the issue I thought I'd seen in that PR but then couldn't reproduce at all later). Want to submit it or should I?

I won't be able to make a proper commit for about 24 hours, but I'm happy if you want to commit a proper solution before then. 👍

jlsalvador commented 1 day ago

tests/zfs-tests/cmd/getversion.c needs as fallback:

#ifdef _KERNEL
#include <sys/fcntl.h>
#else
#include <fcntl.h>
#endif

This does not fix the issue.

jlsalvador commented 1 day ago

Moving fcntl.h before linux/fs.h fix the problem. Debugging and testing for others toolchains (glibc, musl and uclibc) before the PR.

jlsalvador commented 1 day ago

Just moving fcntl.h before linux/fs.h is good enough for uClibc. @thesamesam can you test my PR (https://github.com/openzfs/zfs/pull/16741) in your environment?