mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-27 20:04:23 +01:00
Merge 'io_uring: setup plumbing for Fixed opcodes' from Preston Thorpe
This PR by itself is uninteresting and doesn't do anything. But I am heavily trying to avoid massive PR's, and this is very merge-able 😄 Closes #2396
This commit is contained in:
@@ -105,6 +105,10 @@ impl UringIO {
|
||||
};
|
||||
// we only ever have 2 files open at a time for the moment
|
||||
ring.submitter().register_files_sparse(FILES)?;
|
||||
// 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.
|
||||
ring.submitter().register_buffers_sparse(1)?;
|
||||
let inner = InnerUringIO {
|
||||
ring: WrappedIOUring {
|
||||
ring,
|
||||
@@ -460,6 +464,26 @@ impl IO for UringIO {
|
||||
fn get_memory_io(&self) -> Arc<MemoryIO> {
|
||||
Arc::new(MemoryIO::new())
|
||||
}
|
||||
|
||||
fn register_fixed_buffer(&self, ptr: std::ptr::NonNull<u8>, 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 {
|
||||
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 {
|
||||
|
||||
@@ -2,6 +2,7 @@ use crate::Result;
|
||||
use bitflags::bitflags;
|
||||
use cfg_block::cfg_block;
|
||||
use std::fmt;
|
||||
use std::ptr::NonNull;
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
cell::{Cell, Ref, RefCell, RefMut},
|
||||
@@ -89,6 +90,12 @@ pub trait IO: Clock + Send + Sync {
|
||||
fn generate_random_number(&self) -> i64;
|
||||
|
||||
fn get_memory_io(&self) -> Arc<MemoryIO>;
|
||||
|
||||
fn register_fixed_buffer(&self, _ptr: NonNull<u8>, _len: usize) -> Result<()> {
|
||||
Err(crate::LimboError::InternalError(
|
||||
"unsupported operation".to_string(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
pub type Complete = dyn Fn(Arc<RefCell<Buffer>>, i32);
|
||||
|
||||
Reference in New Issue
Block a user