-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Lift userspace definitions out of zfs_context.h
#17861
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
e75afb5 to
5d26232
Compare
behlendorf
left a comment
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.
Very nice! Aside from a a couple small nits this is a welcome bit of long overdue refactoring.
For next steps I think it would make the most sense to move the remaining user space implementations out of libzpool and into libspl. It looks like lib/libzpool/kernel.c and lib/libzpool/taskq.c should cover almost everything.
Do you want to tackle that in this PR or another? I'm fine with pulling in this whole stack of commits, having it broken up made it much easier to review.
|
Actually, responding to both your comments, I realised what happened here: Both those functions are very libzpool-specific, so they can either say in I'll give it a try. I think there's at least enough overlap with this PR that it could go here, but I'll see how it shakes out - if its ick enough, maybe the next PR is better. More soon! |
5d26232 to
c7b256c
Compare
|
@behlendorf ok, here we go. This actually doubles the size of the PR, but I'm not sure it cleanly splits into two. Let me know what you think. If I don't split, I should rewrite the OP at least. The whole thing here is ensuring the the implementations of things live in the same place as their headers. So there's a bunch of stuff moved over to It's a lot, but I think it lands in a good place. |
|
This is looking good, and it definitely feels like we're moving in the right direction. Where I'd really like to end up is only including the I took the liberty of pushing this PR a bit further with the above goal in mind. What do think of these proposed additions from https://github.com/behlendorf/zfs/tree/userspace-context-lift-part-2.
It might be a good idea to go even farther and move the headers in to |
Agreed,
Yeah, I was holding off on
I think this is going in the opposite direction to what I was aiming for. I want to remove This is not perfectly drawn though, and maybe you have a different vision for it?
Yeah, that works for me for now. In a couple of work/prototype branches (most notably a new unified tunables infrastructure) I concluded that the SPL has to be considered as an extension of the platform, so anything we want to do with eg probes will have to be done directly using platform-specific idioms. So more to do, but we're in agreement here.
Yeah, that's the right thing to do.
Yep, for sure! (incidentally; making libicp optional in userspace and allowing OpenSSL etc to be used is another thing I intent to do, and have a working prototype for already).
Aha this is exactly where I want to take it, but I found that the split has to happen first to even make it tractable. |
Yup, that makes sense. It's going to take a little work to tease this all apart.
Agreed. Adding a
Exactly. It'd be nice to eventually move this down in the SPL layer and tie it in more closely with the platform. But as it currently stands we're not there, so we might as well be honest about it in the layering. Great, it sounds like we're on the same page about all of this. Regard this PR, if you can sort out the remaining build failures I'm comfortable with merging it. It's probably better to do that sooner rather than latter to avoid this getting stale. Then follow up with the next round of refactoring. |
32c1c89 to
9befc34
Compare
|
@behlendorf great to hear we're on the same page! Last push is rebased to master, includes four of your five commits, with some small adjustments to address a few more missed things from the FreeBSD build. If the builders approve, I think we're good! |
|
I'm working on the ABI stuff now. Worst case, I just dump it in as-is, but I notice that we're now exposing a lot of As for the others, I need to go back and do all the compile checks again against older kernels, make sure that different sets of defines are including the right things in the right places. Bit painful, but I'm really happy about the number of quirks and hacks this work has shaken out :) |
|
Last push is a reorg of the lib makefiles and dependencies. I want to see what |
72524dc to
fa7ff13
Compare
|
@behlendorf last push is a rebase, and adding the ABI files as-is. It should be no big deal for this dev cycle at least, as we're not removing any symbols, only adding them (all of I've got a reorg coming to try to fix up symbol visibility in the libs we produce, but its kind of a nightmare and very invasive. I tried to do it on top of master first, but it's just as invasive and also different because the line between (FWIW, #17909 is a bit of support for that work, and you can see what I'm working on in robn@0a08eb3, though it's not yet where I want it.) |
|
Build failures are: Locally, it's ok for me: My guess; the Redhat-flavoured compiler or autotools is putting Probably the real issue is |
73498ea to
00f8cdd
Compare
|
Lets see how that goes. Maybe the only missing piece was |
00f8cdd to
d82948c
Compare
|
And one more. This does fully decouple (Still don't get why its only happening on Redhat flavours though). |
d82948c to
ff947b5
Compare
|
Aha, not "Redhat flavours"! Not exactly. On those, we build Here we go then! 🤞 |
|
@behlendorf that might be it! |
|
Yup, I think we're we're there for this round of changes! I'd just like to get #17911 merged first to finalize the libzfs7 and libzpool7 ABI for the 2.4 release branch. Then we can get this PR merged and I'm hoping work on cleaning up these library interfaces and headers. It may be aspirational, but at least for libzfs.so I'd love to get to the point where we don't have to bump the major version bump for each release. That seems very doable with some minor refactoring of the headers to not expose more than we need too. As for libzpool that's harder, but perhaps we could still provide a minimal useful stable interface. I'm not convinced we really want to limit ourselves in that way, but it's something to discuss. |
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
sys/debug.h is not really the right place for them, but we already have some there for libspl, so it is at least convenient. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
These are kind-of compiler attribute placeholders, so go here with the others for now. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Pull all of the internal debug infrastructure up in to the zfs code to clean up the layering. Remove all the dodgy usage of SET_ERROR and DTRACE_PROBE from the spl. Luckily it was lightly used in the spl layer so we're not losing much. Sponsored-by: https://despairlabs.com/sponsor/ Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
This is mostly a placeholder; it's not actually clear if a boot environment makes any sense for userspace. Still, "posix" is the likely future name of libzpool as a port, and this define is mandatory, so lets roll with it for now. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Only include the zfs headers where they're currently required to compile. Unfortunately, including zfs_ioctl.h in user space pulls in a bunch of internal zfs headers as a side effect. We'll need to move these structures in to a new shared header to avoid this. We should not need to add the LIBZPOOL_CPPFLAGS when building the zed, zinject, zpool, libzfs, ior libzfs_core. Sponsored-by: https://despairlabs.com/sponsor/ Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Only include the required icp headers. There's no need to include sys/zfs_context.h and pull in all of the zfs headers. Sponsored-by: https://despairlabs.com/sponsor/ Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Sponsored-by: https://despairlabs.com/sponsor/ Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
This isn't used by libicp directly, but is by some clients, and relies on headers specific to the zfs module, which makes using it difficult otherwise. Also switch the checksum tests over to use libzpool, so they can get access to it. That's not exactly what we want in the long term, but the icp and zfs modules have a complicated relationship so this will do for now. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
Currently libspl is a static archive that is linked into multiple shared objects, which then re-export its symbols. We intend to fix this soon. For the moment though, most programs shipped with OpenZFS depend on two or more of these shared objects, and see the same symbols twice. For functions this is not a problem, as they do not have any mutable state and so the linker can simply select the first one and use that for all. For global data objects however, each shared object will have direct (non-relocatable) references to its own instance of the symbol, such that changes on one will not necessarily be seen by the other. While this shouldn't be a problem in practice as these reexported interfaces are not supposed to be used, they are technically undefined behaviour in C (C17 6.9.2) and are reported by ASAN as a violation of C++'s "One Definition Rule". To fix this, we hide these globals inside their compilation units, and add access functions and macros as appropriate to preserve the existing API (though not ABI). Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
ztest wants to force all kernel random calls to use the pseudo-random generator (/dev/urandom), to avoid depleting the system entropy pool just for testing. Up until the previous commit, it did this by switching the path that the libzpool (now libspl) random API would use to get random data from; that is, it took advantage of an implementation detail. Now that that hole is closed to it, we need another method. This commit introduces that; a simple API call to enable/disable "force pseudo" mode. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
In theory they should not have resulted in a change. In practice, the way visibility is set up currently means that many of our convenience libraries will "leak through" into the available symbols in our public libraries. In this commit, we're seeing all the new symbols in libspl through libuutil, libzfs and libzfs_core. Importantly, none have been removed, so consumers of these libraries will not notice. Sponsored-by: https://despairlabs.com/sponsor/ Signed-off-by: Rob Norris <robn@despairlabs.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #17861
|
Merged! Thanks for iterating with me on this Rob. As part of the merge I refreshed to top-commit to resolve the ABI file conflicts. |
|
@behlendorf thank you, this was fun! On to the next one! |
Motivation and Context
As part of my ongoing project to make userspace into a "first class" platform, and to make OpenZFS easier to port to other platforms, I am working to make headers consistent across all platforms. I would like to get to a point where
zfs_context.his the same for all platforms and compile modes, and so provides a complete list of "necessary to implement" for any platform.The first part of that is to lift all the userspace-specific stuff out of
zfs_context.hinto separated headers inlib/libspl/include. That's this PR.This PR deliberately stops at emptying
zfs_context.hof definitions. The next PR I open on this project will collapse it into a single list of headers that works across all platforms, but that will require movement across all platform headers, not just userspace, and I don't want to complicate review on this further.Description
There's a lot of commits here, but they are basically just picking a specific concept or object from the userspace part
zfs_context.hand moving it out to a specific header underlib/libspl/include. For most, that header does not already exist. For some, it does exist but wasn't used, or was in conflict, and has been updated appropriately.After that, there's a long tail of misc stuff, which has been either moved somewhere more appropriate or deleted.
I expect that much of this could be collapsed into a smaller set of commits, but for the moment I'm keeping them separate for review.
How Has This Been Tested?
This should all be entirely mechanical, so anything that compiles should work.
The final series compiles on Linux and FreeBSD, and ZTS passes.
It should compile clean at each individual commit, but I have moved things around a little while assembling the final series, so something may be stacked wrong. I'll go and check that now, but its also pretty low-key.
Types of changes
Checklist:
Signed-off-by.