Repository navigation
Conversation
Berrysoft
requested changes
Nov 11, 2026
| // The result of a zerocopy notification is a set of flags, not an | ||
| // errno: with `IORING_SEND_ZC_REPORT_USAGE` the kernel sets | ||
| // `IORING_NOTIF_USAGE_ZC_COPIED` (`1 << 31`) when the data was copied. | ||
| Ok(result as u32 as usize) |
Member
There was a problem hiding this comment.
Should clear the flag instead of a conversion.
Contributor
Author
There was a problem hiding this comment.
Makes sense, clearing the bit is much cleaner. The notification now just completes with Ok(0), and whether the data was copied shows up as Extra::zc_copied().
| //! A zerocopy notification reports its usage in the sign bit of `res`, which | ||
| //! must not be read as an errno. | ||
|
|
||
| #![cfg(all(io_uring, not(fusion)))] |
Contributor
Author
There was a problem hiding this comment.
I added a fusion run to the test now.
The driver now clears IORING_NOTIF_USAGE_ZC_COPIED from the res of a zerocopy notification, so the result is Ok(0) like any other success, and reports the flag through Extra::zc_copied. The test also runs on the fusion driver.
Member
|
The idea is good, but the code tastes... @George-Miao would you have a look? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
resof a zerocopy notification isn't an errno. When the send setsIORING_SEND_ZC_REPORT_USAGE, the kernel putsIORING_NOTIF_USAGE_ZC_COPIED(1 << 31) there if it copied the data (uapi, v6.2, notif.c).create_resultreads it as a negative errno and negates it (iour/mod.rs).-i32::MINoverflows, so a debug build panics and a release build returns anio::Errorwith a garbage code.compio's own
SendZcops don't set the flag, but anyOpCodethat setszc_flagsto get the usage report runs into this.create_entrynow clearsIORING_NOTIF_USAGE_ZC_COPIEDfrom theresof a notification (IORING_CQE_F_NOTIF), so it completes withOk(0), and passes the bit on asExtra::zc_copied().The new test sends over loopback with
REPORT_USAGE, where the kernel always copies, and checks that the notification reports the copy. On master it panics with "attempt to negate with overflow"; with this change it passes on Linux 6.18. It skips on kernels that reject the flag. It also runs on the fusion driver.