-
Notifications
You must be signed in to change notification settings - Fork 163
implement fd passthrough support #336
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
|
Some notes:
This leaves a little bit to be desired in terms of clarity about exactly when it's OK, so I figured that I'd document that you should close it at
|
Yes, you'll need to add all the fields, or at least reserve space for them, so that fuser parses the right number of bytes
Breaking the API is fine, if it's necessary for supporting new FUSE features. That's why we're still on version zero :) |
music to my ears |
|
Some discussion here about the Obviously this doesn't block this PR in any way whatsoever... but it might be useful to have something to write in the doc comment... |
Recent upstream kernel releases have added more than 32 bits worth of flags for the init message by adding 'flags2' fields on the message types. In order to prepare for this change, let's first change the types of our existing init flags to u64. This is an API break, but most users won't notice, unless they were explicitly specifying the type of the flags somewhere. None of the examples are impacted. This change is limited to the high-level API that we expose to users. At the kernel ABI level, we currently just convert u32 to u64 and back. That will change in the following commits.
a15dbe8 to
a293063
Compare
|
This should be vaguely reviewable now... |
a293063 to
0545754
Compare
Kernel commit 53db28933e95 ("fuse: extend init flags") added a `flags2`
field to the 'in' and 'out' init messages. Add support for those,
ourselves.
This introduces a feature flag for ABI version 7.36, but skips the ABI
versions between.
0545754 to
1f5e123
Compare
|
I read it, but I don't feel qualified to judge it. I think the hash maps need a //comment to explain what is being mapped to what. (inode to fh? something else?). the type isn't giving enough information. |
cberner
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.
It would be nice to have a test for this feature. I haven't taken the time to create a nice way to test features like this, and mostly have relied on the xfstests and pjdfstests. But maybe a shell script like I used in this other project or a new integration test in tests/?
I had a few other comments, but overall it looks reasonable to me
src/lib.rs
Outdated
| /// | ||
| /// The kernel currently has a hard maximum value of 2. Anything higher won't work. | ||
| #[cfg(feature = "abi-7-40")] | ||
| pub fn set_max_stack_depth(&mut self, value: u32) { |
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.
Let's return a Result like some of the other methods do
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.
Interesting idea. I'm not sure what I'd return here, though. We could check for >2 and return Err(2), of course, but we don't have any actual way of know that via kernel interaction, as far as I know....
That said, it is defined in a public header, <linux/fs.h>:
/*
* Maximum number of layers of fs stack. Needs to be limited to
* prevent kernel stack overflow
*/
#define FILESYSTEM_MAX_STACK_DEPTH 2so maybe we just ought to expose that and use it to do the check?
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 guess my concern here is if it's ever raised we might be inappropriately enforcing a restriction that's no longer true...
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.
erm, ya. Sorry. It's not in <linux/fs.h> but rather in linux/include/linux/fs.h, which is not installed. That's sort of exactly my problem with enforcing an actual limit here...
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 wrote to fsdevel asking for clarification...
Let's see what they say.
|
btw: I'm kinda a rust newb. Can anyone help me with why |
|
Do you have the correct --feature enabled? Some of the examples are feature depandant. |
You need to pass |
Seems unfortunate. It would be nice if it worked the other way around (each example pulled in its required feature set)... It worked, though! |
This largely corresponds to changes introduced in 7dc4e97a4f9a ("fuse:
introduce FUSE_PASSTHROUGH capability").
Add a new 'abi-7-40' feature flag and make some changes if it's set:
- the `padding` field on `fuse_open_out` is renamed to `backing_id`
- add a new `max_stack_depth field` to `fuse_init_out`
- new `FUSE_PASSTHROUGH` init flag
- new `FOPEN_PASSTHROUGH` `fuse_open_out` flag
Add some asserts to the existing reply APIs to ensure that the user
can't use the FUSE_PASSTHROUGH flag: we will soon introduce a version of
these APIs that operate with passthrough fds.
Add an API for setting max_stack_depth to KernelConfig as well.
Add a new BackingId wrapper API in a new file (passhthrough.rs) to support creating and sending "Backing IDs" for passthrough fds. Doing this requires performing ioctls: we enable the feature on the nix crate if our ABI version is 7.40 or greater. Closes cberner#297
This is copied from the same template as the other examples. It includes an example of how a filesystem might choose to cache and reuse BackingIds.
1f5e123 to
f125612
Compare
cberner
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.
lgtm, but see my comment on the passthrough test
f125612 to
5e30845
Compare
That's the line: config.add_capabilities(consts::FUSE_PASSTHROUGH).unwrap();and 137438953472 is 0x2000000000, which is the value of I guess that means that the kernel on the GitHub runner doesn't support passthrough. That's not surprising: https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md says
The version on the 24.04 OS image:
and apparently passthrough went in around 6.9. Should we update the image for the workflow? |
5e30845 to
c0437b4
Compare
Oops. Typo. Once more around :) |
c0437b4 to
92545bb
Compare
...and run it from CI via `make test_passthrough`. We need to upgrade to ubuntu-24.04 in order to do this because we need a kernel with passthrough support.
92545bb to
091d2b0
Compare
|
Merged. Thanks! |
|
I need help adapting this feature to work with the return result paradigm (PR #345). |
This is going to need a lot of love. Feedback extremely welcome!