Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/cp_files: fallback for C libs w/o SEEK_DATA #16169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jlsalvador
Copy link
Contributor

Not all C libraries support SEEK_DATA (e.g., uClibc). When SEEK_DATA is not defined, fallback to SEEK_END.

Motivation and Context

Currently, uClibc does not compile OpenZFS because the test cp_files uses SEEK_DATA as the whence parameter for the lseek method.

Description

When SEEK_DATA is not defined, use SEEK_END as the fallback value.

How Has This Been Tested?

  • Compiling Buildroot with a preliminary patch version using GLIBC, UCLIBC, and MUSL as toolchains.
  • Running the ZFS Test Suite with this change applied, although the affected test was skipped due to a kernel configuration for Debian 12.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@jlsalvador
Copy link
Contributor Author

Hello all,

Any alternative instead of SEEK_END?
Thoughts?

@rincebrain
Copy link
Contributor

I think the right thing to do, if SEEK_DATA/SEEK_HOLE are not available, is to make all the tests that rely on that constant get marked SKIP, rather than substituting one with different semantics to test.

I'd probably do this with a configure time check that checked for support for those and then defined something for the test suite and that test program to change their behavior around, but that's off the top of my head, I don't know offhand how we do this for other platform-specific checks.

@behlendorf
Copy link
Contributor

Right, instead of changing the behavior of this test we should disable it as @rincebrain suggested.

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label May 9, 2024
@robn
Copy link
Contributor

robn commented May 10, 2024

Another option would be to define those two if they're missing:

#ifndef SEEK_DATA
#define SEEK_DATA 3
#endif
#ifndef SEEK_HOLE
#define SEEK_HOLE 4
#endif

That particular value gets passed directly into SYS__llseek in the kernel, so it should always work on any Linux kernel.

Though as I type is, I feel a little uncomfortable about it. Disabling makes more sense. @jlsalvador if you'd like a hand with the detection bits, let me know - I do know my way around that stuff.

@jlsalvador jlsalvador force-pushed the feature/tests_cp_files_fallback_for_seek_data branch from 5ff16e9 to 68e5cfe Compare May 11, 2024 23:03
@jlsalvador
Copy link
Contributor Author

jlsalvador commented May 11, 2024

Hello again,

I force-pushed a commit with another solution as @rincebrain suggested.

I have made a few assumptions. Could someone please check if the patch follows the ZFS guidelines?

Perhaps someone could improve it by skipping the test case at runtime (printing [SKIP]) instead of ignoring it with a new AutoMake conditional (WANT_UNISTD_SEEK_DATA).

I tested it by building Buildroot using GLIBC, UCLIBC, and MUSL toolchains.
Currently I am running the ZFS Test Suite on a Debian 12 (./configure --disable-pyzfs), it requires a few hours to finish.


@robn, thank you for offering to help. Could you please confirm if the patch is correct?

@behlendorf
Copy link
Contributor

Perhaps someone could improve it by skipping the test case at runtime (printing [SKIP]) instead of ignoring it with a new

The way we've handled this before is to only build the cp_files and seekflood binaries when SEEK_DATA / SEEK_HOLE are available. Which is what you've already done. Then at the top of each relevant test add a check for the binary. If it doesn't exist call log_unsupported with a meaningful error message which will cause the script to exist. You'll also need to update zts-report.py.in to understand these tests may be skipped. The Linux specific tmpfile tests provide a good example of this.

Not all C libraries support SEEK_DATA (e.g., uClibc). Skip the test case
cp_files if SEEK_DATA is not defined.

Signed-off-by: José Luis Salvador Rufo <salvador.joseluis@gmail.com>
@jlsalvador jlsalvador force-pushed the feature/tests_cp_files_fallback_for_seek_data branch from 68e5cfe to f893ed9 Compare May 29, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Code Review Needed Ready for review and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants