-
Notifications
You must be signed in to change notification settings - Fork 177
Description
Recently, Linux has supported a userspace block device implementation, called ublk.
It supports a feature called Auto Buffer Registration, which needs to set sqe->addr to some special value. The following paragraph is quoted from the documentation of ublk:
Buffer registration data must be passed via uring_cmd’s sqe->addr with the following structure:
struct ublk_auto_buf_reg { __u16 index; /* Buffer index for registration */ __u8 flags; /* Registration flags */ __u8 reserved0; /* Reserved for future use */ __u32 reserved1; /* Reserved for future use */ };ublk_auto_buf_reg_to_sqe_addr() is for converting the above structure into sqe->addr.
In short, I need to set .addr after build a io_uring::squeue::Entry.
Specifically, the currently bindings from tokio-rs iouring (x86_64) is:
#[repr(C)]
pub struct io_uring_sqe {
pub opcode: __u8,
pub flags: __u8,
pub ioprio: __u16,
pub fd: __s32,
pub __bindgen_anon_1: io_uring_sqe__bindgen_ty_1,
pub __bindgen_anon_2: io_uring_sqe__bindgen_ty_2,
pub len: __u32,
pub __bindgen_anon_3: io_uring_sqe__bindgen_ty_3,
pub user_data: __u64,
pub __bindgen_anon_4: io_uring_sqe__bindgen_ty_4,
pub personality: __u16,
pub __bindgen_anon_5: io_uring_sqe__bindgen_ty_5,
pub __bindgen_anon_6: io_uring_sqe__bindgen_ty_6,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union io_uring_sqe__bindgen_ty_2 {
pub addr: __u64,
pub splice_off_in: __u64,
pub __bindgen_anon_1: io_uring_sqe__bindgen_ty_2__bindgen_ty_1,
}I need to update the io_uring_sqe.__bindgen_anon_2.addr.
Does tokio-rs/io_uring plan to achieve this? Or should we workround by ourselves?
The current workaround is like those in libublk-rs
// Define a struct by ourselves
#[repr(C)]
pub struct RawSqe {
opcode: u8,
flags: u8,
ioprio: u16,
fd: i32,
off: u64,
pub addr: u64,
pub len: u32,
pub rw_flags: u32,
user_data: u64,
pub buf_index: u16,
personality: u16,
splice_fd_in: i32,
__pad2: u32,
}
unsafe {
let sqe: &mut RawSqe = std::mem::transmute(&mut sqe); // transmute the io_uring::squeue::Entry
sqe.addr = xxx;
}