-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
vdev_file: unify FreeBSD and Linux implementations #17046
Conversation
You glanced at macOS and Windows to see if there are any upcoming surprises? |
@lundman Nope, because even if I had I don't know what the current plan is for them. I take it that means this is a breaking change. Tell me more? Are there changes there that require more than the (admittedly limited) |
Not at all, I took a look now, and Windows doesn't look too bad, some path work before open. |
I was just skimming myself, and didn't see anything too weird, though obviously I know nothing about it. Does seem like we could extend zfs_file to have a path transform hook of some sort. I did wonder if it'd be better if it would be better if vdev_file went the other way, and properly separate for each platform (incl userspace), but at least on Linux+FreeBSD, we use in other places. Not much actually file-ish once you take send/recv away (maybe only The other possibility is to make zfs_file fully async, ie every func gets called with a callback function, and any required taskqs are pushed down there instead. I don't even mind that, makes it more like a device, and vdev_file more like a driver for it. I have not thought about this even a little bit. I'll have a look soon (hopefully tonight) at the extra hooks mac/win might need. It might be straightforward to add those hooks in this PR and so avoid making a huge mess for you (just a small one) :) |
I wouldn't worry about hooks just yet, be better to do that when I have caught up and can test it directly :) |
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.
One small nit
735b6e5
to
8a98df1
Compare
@robn I think this is ready to go. Would you mind squashing the commits? |
Kernel & userspace specifics are in zfs_file_os.c, so there's no particular reason these have to be separate. The one platform-specific part is in the Linux kernel part, to offload flushes to a taskq if we're already inside a filesystem transaction. This would be normally be an unsatisfying wart, but I'm intending to remove this shortly, so I'm content to leave it gated for the moment. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Signed-off-by: Rob Norris <[email protected]>
8a98df1
to
a7a5eae
Compare
[Sponsors: Klara, Inc., Wasabi Technology, Inc.]
Motivation and Context
The platform-specifics for
vdev_file
are almost entirely hidden away inzfs_file_os.c
. There's basically no reason for separatevdev_file.c
to exist, so lets merge them.Description
The process here was to load both files side-by-side in
vimdiff
, then move things around until there was no diff left. Where there were differences, I've taken the "best" version, though this is almost entirely in comments and asserts.There are very minor changes to make it fit together sensibly:
Both:
zio_interrupt()
instead of executed directly (slightly nicer behaviour, and allows reuse of thevdev_file_io_fsync()
in the inline case.FreeBSD:
zfs_nocacheflush
for FLUSH ZIOs. This matches Linux, userspace, disk drivers for both platforms, and the documentation.Linux+userspace:
z_vdev_file
is created usingmax_ncpus
rather thanboot_ncpus
. I don't think there will be any practical difference.The one wart is the Linux-specific thing to put flushes on the taskq if called within an filesystem transaction. For now I've gated that behind
#ifdef __linux__
. I wouldn't normally leave it there, but the reason I did this change at all is because I've got a change coming that always puts flushes on the taskq, so the wart will be removed with that.I've put the respective diffs for each platform in their own commit, so the changes can be more easily seen. If this is approved, I will squash the commits before merge.
How Has This Been Tested?
Compiled on FreeBSD 14.2, Linux 6.1 and Linux 4.19. On all, ran
zpool_add
andreplacement
test tags, which aren't special but use file-backed pools, and also changevdev_file
tuneables. All passed.Types of changes
Checklist:
Signed-off-by
.