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

ZTS: small fix for SEEK_DATA/SEEK_HOLE tests #16413

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

mcmilk
Copy link
Contributor

@mcmilk mcmilk commented Aug 4, 2024

Motivation and Context

Some libc's like uClibc lag the proper definition of SEEK_DATA and SEEK_HOLE.
Since we have only two files in ZTS which use these definitons, let's define them by hand.

There should be no failures, because:

  • FreeBSD has support for SEEK_DATA/SEEK_HOLE since FreeBSD 8
  • Linux has it since Linux 3.1
  • the libc will submit the parameters unchanged to the kernel

There is another pull request for fixing this by skipping the tests here: #16169.
This one is a bit more complex and not finished currently.

Description

I would prefer to make the needed definitions by hand for now:

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

Some more details about the Defines themself:

So in the end, ZTS uses the Defines here:

  1. tests/zfs-tests/cmd/mmap_seek.c
  2. tests/zfs-tests/tests/functional/cp_files/seekflood.c

So let's define them in order to do the tests on uClibc based ZTS runs also.

How Has This Been Tested?

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:

@mcmilk mcmilk force-pushed the fix-seek-data-for-uclibc branch from 619eb33 to fbe3375 Compare August 4, 2024 11:45
@jlsalvador
Copy link
Contributor

jlsalvador commented Aug 4, 2024

Are you sure that defining this does not crash at runtime?

https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/libc/sysdeps/linux/common/lseek.c?id=05b11809bd11450aff3d20e43f18415ce58601e7#n44

	switch(whence) {
		case SEEK_SET:
		case SEEK_CUR:
		case SEEK_END:
			break;
		default:
			__set_errno(EINVAL);
			return -1;
	}

@mcmilk
Copy link
Contributor Author

mcmilk commented Aug 4, 2024

Are you sure that defining this does not crash at runtime?

The test will fail then, because the seek will return -1, that should be fine.

https://github.com/kraj/uclibc-ng/blob/dc3ad9110793e67b13421135f714085cb8ab3c68/libc/sysdeps/linux/common/lseek.c#L39

	switch(whence) {
		case SEEK_SET:
		case SEEK_CUR:
		case SEEK_END:
			break;
		default:
			__set_errno(EINVAL);
			return -1;
	}

I didn't check uClibc itself. Is there a way that uClibc will get support for it?

Edit: oh, uClibc was last updated in 2012?!

I can change my PR so that it handles EINVAL ... and creates a skipped test.

@satmandu satmandu mentioned this pull request Aug 5, 2024
13 tasks
Some libc's like uClibc lag the proper definition of SEEK_DATA
and SEEK_HOLE. Since we have only two files in ZTS which use
these definitons, let's define them by hand:

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

There should be no failures, because:
- FreeBSD has support for SEEK_DATA/SEEK_HOLE since FreeBSD 8
- Linux has it since Linux 3.1
- the libc will submit the parameters unchanged to the kernel

Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
@mcmilk mcmilk force-pushed the fix-seek-data-for-uclibc branch from fbe3375 to 2ccefd4 Compare August 6, 2024 18:09
@jlsalvador
Copy link
Contributor

I have already tested this patch for Buildroot (uClibc). It works correctly 👏. Thank you all!

@behlendorf behlendorf added the Status: Accepted Ready to integrate (reviewed, tested) label Aug 7, 2024
@tonyhutter tonyhutter merged commit bd949b1 into openzfs:master Aug 7, 2024
20 of 24 checks passed
@mcmilk mcmilk deleted the fix-seek-data-for-uclibc branch August 24, 2024 13:36
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Sep 4, 2024
Some libc's like uClibc lag the proper definition of SEEK_DATA
and SEEK_HOLE. Since we have only two files in ZTS which use
these definitons, let's define them by hand:

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

There should be no failures, because:
- FreeBSD has support for SEEK_DATA/SEEK_HOLE since FreeBSD 8
- Linux has it since Linux 3.1
- the libc will submit the parameters unchanged to the kernel

Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
robn pushed a commit to robn/zfs that referenced this pull request Nov 5, 2024
Some libc's like uClibc lag the proper definition of SEEK_DATA
and SEEK_HOLE. Since we have only two files in ZTS which use
these definitons, let's define them by hand:

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

There should be no failures, because:
- FreeBSD has support for SEEK_DATA/SEEK_HOLE since FreeBSD 8
- Linux has it since Linux 3.1
- the libc will submit the parameters unchanged to the kernel

Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants