-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add FreeBSD posix_fadvise support #17379
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
I've been reading the Linux side a bit this evening, and I am almost certain that the call to First, As for the behaviour, it seems the call does some error checks (which we also do), then gets into a switch on For In any case, I don't think you're gonna break anything by leaving that shape out on the FreeBSD side. |
@fuporovvStack Please take a look. |
1. 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.) 2. 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]>
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.
Looks good. I wondered about the call to generic_fadvise()
myself, going back to the comments in the original issue it was added as a performance optimization to force populate the page cache. Which makes some sense.
If the file is mmaped, generic_fadvise is also called for page cache read-ahead besides dmu_prefetch.
So there is no correctness issue there.
This is a rebase/refresh of #13958 by @macdice.
As commit 320f0c6 did for Linux, connect POSIX_FADV_WILLNEED up to dmu_prefetch() on FreeBSD.
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
.