-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
avoid symbol collision with in-kernel zstdlib #10775
Conversation
ba080d2
to
2df4a81
Compare
Clean PR, nice work @BrainSlayer |
b3c5d1a
to
a0fee60
Compare
@Ornias1993 first time for me that something is not dirty :-) |
@BrainSlayer Lets not go there shall we ;-) Question: there is no option to wildcard define in header files? |
not that i know. you can do something like but this will not help since i cannot do #define RENAME(func) #define func zfs_ ## func i just used "nm" and a awk script to generate the header. so its simple to renew it |
hint: the same problem might affect freebsd which has also a in kernel zstd library. but zfs isnt build yet static into the freebsd kernel. but i wait for comments first |
@BrainSlayer Good points indeed. |
not usefull since i hand crafted it after generating. i needed to remove compiler generated symbols and the function zstd_isError which would collide with another macro definition in zstd.h. and i needed to modify the result for passing cstyle check of zfs nm zstd.o | awk '{print "#define "$3 " zfs_" $3}' > rename.h |
It builds for me. Thanks @BrainSlayer |
thx. will set it to review now and i hope it gets merged soon |
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.
Thanks for sorting this out and opening a PR.
Codecov Report
@@ Coverage Diff @@
## master #10775 +/- ##
==========================================
- Coverage 79.62% 79.60% -0.03%
==========================================
Files 395 395
Lines 125039 125039
==========================================
- Hits 99567 99541 -26
- Misses 25472 25498 +26
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
Please also add an explanation to the readme, describing the fact this new headerfile needs to be updated accordingly when we update to new ZSTD versions .
Besides those points this looks good and build, thanks for the effort @BrainSlayer and glad to have this issue fixed with due priority! 🥇
it doesnt need to be updated as far as it covers the symbols used in the kernel and this is unlikelly to be changed very soon. i rename much more symbols than required |
It needs a short and simple single scentence as a reminder. Remember: This is meant for years from now too. Something like: |
not my style. i will not tell 3rd parties to update headers to stay compatible. thats our responsibility. i just said its not likelly that the in-kernel zstd changes the symbol names nor will they add new names. this wrapper is a workarround for all zstd symbols used by zfs. so we are safe, since my wrapper renamed all symbols in use by zfs |
The update readme is meant to document all issues that might arrise from updating, this is one of them. It's meant for people in year, 5 years, 10 years or whatever years from now if we are not there to maintain it anymore (which isn't a guarantee) However: |
@BrainSlayer when you get a chance to refresh this and add the short comment to |
348f0b6
to
ad3c115
Compare
@behlendorf i rebased it, compile checked it and added some small documentation to the header |
yes, but this is not neccessary. since we rename all symbols locally in use by zfs, nothing will happen in the kernel lib will be changed. our zfs implementation still has everything renamed. if we update zstd in future within zfs, we need usually to check if we need to update the symbols. i added also a small comment to the header about it |
ad3c115
to
5eb4cfb
Compare
We made a seperate Readme listing all the things that need to be checked when updating the integrated zstd lib. as you said: this is one of those. |
5eb4cfb
to
3a9cc7d
Compare
README updated |
@BrainSlayer Thank you! :) |
3a9cc7d
to
777e308
Compare
better? |
@BrainSlayer Yeah, I see the file now. LGTM. :) |
@BrainSlayer Is this error related or a separate issue?
I'm assuming this happens because I'm building both btrfs and zfs statically and they both define a zstd_decompress function in which case building btrfs as a module might fix this (I don't need it statically anymore since I only have one btrfs drive now and my rootfs is on zfs, I've just always done it that way and never changed my kernel config)? |
you got it. this happens if you staticly compile zfs into the kernel. but your error extends this bug, since btrfs seem to use the same symbol name as zfs. let me update my patch to cover your issue
|
@BrainSlayer |
777e308
to
b4f279c
Compare
can you link it? i dont know how to link the PR to this issue. i commited now a fix for the other issue to and renamed the zstd_decompess/zstd_compress functions to be prefixed with zfs_ |
@BrainSlayer Seems you did it alright 👍 |
b4f279c
to
0bac120
Compare
please check if this PR does solve your issue. to make sure its ready for beeing merged |
in case zfs is compiled as in kernel static variant and the in kernel zstd library is compiled static into the kernel, a symbol collision will occur. this wrapper header does rename all relevant zstd functions to avoid this problem Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
0bac120
to
6ff1349
Compare
It builds for me now with Thanks, @BrainSlayer. |
For Linux, when zfs is compiled as an in kernel static variant and the in kernel zstd library is compiled statically into the kernel a symbol collision will occur. This wrapper header renames all of the relevant zstd functions to avoid this problem. Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com> Closes openzfs#10775
For Linux, when zfs is compiled as an in kernel static variant and the in kernel zstd library is compiled statically into the kernel a symbol collision will occur. This wrapper header renames all of the relevant zstd functions to avoid this problem. Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com> Closes openzfs#10775
In case zfs is compiled as in kernel static variant
and the in-kernel zstd library is compiled static into the kernel, a
symbol collision will occur. this wrapper header does rename all
relevant zstd function to avoid this problem
closes #10763
Signed-off-by: Sebastian Gottschall s.gottschall@dd-wrt.com
Motivation and Context
Description
How Has This Been Tested?
Types of changes
Checklist:
Signed-off-by
.