From 9289dd7e9a8f9be491d993672c4987a2f38a511d Mon Sep 17 00:00:00 2001 From: PThorpe92 Date: Fri, 1 Aug 2025 14:55:35 -0400 Subject: [PATCH] Implement register_fixed_buffer for io_uring IO backend --- core/io/io_uring.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/core/io/io_uring.rs b/core/io/io_uring.rs index b2afeb652..1fc74cf1e 100644 --- a/core/io/io_uring.rs +++ b/core/io/io_uring.rs @@ -460,6 +460,29 @@ impl IO for UringIO { fn get_memory_io(&self) -> Arc { Arc::new(MemoryIO::new()) } + + fn register_fixed_buffer(&self, ptr: std::ptr::NonNull, len: usize) -> Result<()> { + turso_assert!( + len % 512 == 0, + "fixed buffer length must be logical block aligned" + ); + let inner = self.inner.borrow_mut(); + let default_id = 0; + unsafe { + // RL_MEMLOCK cap is typically 8MB, the current design is to have one large arena + // registered at startup and therefore we can simply use the zero index, falling back + // to similar logic as the existing buffer pool for cases where it is over capacity. + inner.ring.ring.submitter().register_buffers_update( + default_id, + &[libc::iovec { + iov_base: ptr.as_ptr() as *mut libc::c_void, + iov_len: len, + }], + None, + )? + }; + Ok(()) + } } impl Clock for UringIO {