Skip to content

[IO_URING] Accept immutable buffers for unregistered writes - #402

Open
rksharma-owg wants to merge 4 commits into
apple:mainfrom
rksharma-owg:codex/system-400-immutable-writes
Open

rksharma-owg wants to merge 4 commits into
apple:mainfrom
rksharma-owg:codex/system-400-immutable-writes

Conversation

@rksharma-owg

@rksharma-owg rksharma-owg commented Oct 6, 2026 •

Copy link
Copy Markdown

IORing.Request.write required mutable buffers even though a write only reads from them. Add UnsafeRawBufferPointer overloads for both ordinary file descriptors and registered file slots, retaining the existing mutable-buffer signatures and function references.

The new overloads use the existing write request encoder. Their documentation explains buffer lifetime, offsets, completion context and partial writes. Regression tests check the resulting operation, descriptor, address, length, offset and context. A real io_uring pipe test writes an immutable buffer and verifies the received bytes.

Local Linux ARM64 Swift 6.4 validation passed: 81 XCTest cases and 7 Swift Testing tests, including real io_uring execution. The immutable-buffer tests fail to compile before the overloads are added. Mutable function references and inferred buffer-construction calls compile with the fix.

The cloud API breakage check passes against the refreshed target branch.

Fork preflight passed all 49 enabled jobs for 92481cc05652e561623eb32c1411d5d2e4b7fd4d against 486d48c80fce32823218000cf8563d9b4bbbf4a9: Linux, macOS, Windows, FreeBSD, Android emulator tests, static Linux/Wasm SDK builds, ABI-stable macOS builds, CMake and applicable soundness/API checks. Standard container runs skip io_uring when unavailable; the separate kernel write/read-back job executed and passed. Upstream-disabled checks remain inapplicable.

Fixes #400.

Comment on lines +388 to +398
@inlinable public static func write(
_ buffer: UnsafeRawBufferPointer,
into file: IORing.RegisteredFile,
at offset: UInt64 = 0,
context: UInt64 = 0
) -> IORing.Request {
// The shared request encoder uses a mutable pointer, but writes only read the buffer.
write(UnsafeMutableRawBufferPointer(mutating: buffer), into: file, at: offset, context: context)
}

@inlinable public static func write(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we are here can we add doc comments to these methods. Also I am thinking that we should deprecate the other methods since they are just wrong. @jrflat WDYT about deprecating?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[IO_URING] Unregistered write requires a mutable buffer

2 participants