-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add FreeBSD posix_fadvise support. #13958
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
Conversation
7117853
to
ccc7b15
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking about possible integration between dmu_prefetch() and dmu_zfetch(), but that is separate. Otherwise aside one comment I'd be happy to have this (I don't now many apps using it, but good prefetch is a "must have" for a wide pools).
@macdice should this PR be promoted from a draft? Is it ready for review? |
ccc7b15
to
38c2a4b
Compare
As commit 320f0c6 did for Linux, connect POSIX_FADV_WILLNEED up to dmu_prefetch() on FreeBSD. Reviewed-by: Mateusz Guzick <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Thomas Munro <[email protected]> Closes openzfs#13958
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As part of this change it would be best to enable the functional/fadvise/fadvise_sequential.ksh
test case on FreeBSD. It looks like it will just need to be updated to use POSIX_FADV_WILLNEED
instead of POSIX_FADV_SEQUENTIAL
, and to check the arcstats in the correct way for FreeBSD. Aside from that, I'd expect it to work.
As commit 320f0c6 did for Linux, connect POSIX_FADV_WILLNEED up to dmu_prefetch() on FreeBSD. Reviewed-by: Mateusz Guzick <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Thomas Munro <[email protected]> Closes openzfs#13958
As commit 320f0c6 did for Linux, connect POSIX_FADV_WILLNEED up to dmu_prefetch() on FreeBSD. Reviewed-by: Mateusz Guzick <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Thomas Munro <[email protected]> Closes openzfs#13958
As commit 320f0c6 did for Linux, connect POSIX_FADV_WILLNEED up to dmu_prefetch() on FreeBSD. Reviewed-by: Mateusz Guzick <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Thomas Munro <[email protected]> Closes openzfs#13958
As commit 320f0c6 did for Linux, connect POSIX_FADV_WILLNEED up to dmu_prefetch() on FreeBSD. Reviewed-by: Mateusz Guzick <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Thomas Munro <[email protected]> Closes openzfs#13958
38c2a4b
to
ffeb491
Compare
Tests fixed as requested. I had another go at computing the length; I didn't like the way dmu_prefetch loops past the end limited only by the dmu_prefetch_max setting, so I figured we should really check zp->z_size here, and also it was off by one. But now I'm wondering how to read that safely. |
81b4255
to
03f018e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple nits then looks good to me.
@macdice if you can wrap up the few remaining commends and rebase this we can get it merged. |
03f018e
to
3152dc2
Compare
@macdice thanks for updating this. Can you rebase this against the latest version of the master branch and then force update the PR. This should give us a better run of the test suite to make sure everything is in order. |
module/os/freebsd/zfs/zfs_vnops_os.c
Outdated
|
||
/* kern_posix_fadvise points to the last byte, we want one past */ | ||
if (end != OFF_MAX) | ||
end += 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra tab removed
1. Use the existing get_arcstats() function from libtest.shlib to read data_size, instead of directly accessing /proc/spl/kstat/zfs, which FreeBSD doesn't have. 2. Make the regex in libtest.shlib a little stricter, because otherwise data_size also matches metadata_size and the test breaks, which is probably why it was done another way first... 3. Instead of relying on the numerical values of POSIX_FADV_XXX macros, accept macro names as arguments to the file_fadvise program. (The numbers happen to match on Linux and FreeBSD, but future systems may vary and it seems a little strange/raw to count on that.) 4. For implementation reasons, SEQUENTIAL doesn't reach ZFS via FreeBSD VFS currently (perhaps something that should be investigated in FreeBSD). Since on Linux we're treating SEQUENTIAL and WILLNEED the same, it doesn't really matter which one we use, so switch the test over to WILLNEED exercise the new prefetch code on both OSes the same way. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Thomas Munro <[email protected]>
As commit 320f0c6 did for Linux, connect POSIX_FADV_WILLNEED up to dmu_prefetch() on FreeBSD. Reviewed-by: Mateusz Guzik <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Thomas Munro <[email protected]>
3152dc2
to
b224b29
Compare
Hmm. zloop failed with "ASSERT at cmd/ztest.c:5933:ztest_dmu_snapshot_hold()/lib/x86_64-linux-gnu/libasan.so.6(+0x45c0e)[0x7efebc67fc0e]", but when I try it locally I get various other random failures from an asan/ubsan build (on FreeBSD it fails fast, on Linux it fails after a few successful loops), and that's the case with or without my changes. Then there are some functional test failures, for example "functional/casenorm/mixed_formd_lookup (run as root) [00:00] [FAIL]" and those fails for me too, even with my change reverted. So perhaps I rebased onto a bad commit? |
Unfortunately
|
what's the status here? 👀 |
As commit 320f0c6 did for Linux, connect POSIX_FADV_WILLNEED and POSIX_FADV_SEQUENTIAL up to dmu_prefetch() on FreeBSD.
[Draft only, work in progress]
Signed-off-by: Thomas Munro [email protected]
Motivation and Context
See #13694 (née #9807) for motivation and context. The present PR is for feature parity on FreeBSD.
Description
Connects posix_fadvise() to dmu_prefetch().
Quite similar to Linux, but:
How Has This Been Tested?
I have tested on top of the main branch of FreeBSD, which most recently merged OpenZFS master a few days ago (openzfs/zfs commit c629f0b). I've tested with simple programs, and PostgreSQL which generates a WILLNEED advice in various circumstances.
I wonder if we should implement POSIX_FADV_DONTNEED to evict ranges from ARC to facilitate testing, but that'd be another PR.
Types of changes
Checklist:
Signed-off-by
.