diff --git a/src/io.rs b/src/io.rs index 81a6e59..ddf5668 100644 --- a/src/io.rs +++ b/src/io.rs @@ -506,15 +506,13 @@ impl UblkQueue<'_> { let depth = dev.dev_info.queue_depth as u32; let cdev_fd = dev.cdev_file.as_raw_fd(); let cmd_buf_sz = UblkQueue::cmd_buf_sz(depth) as usize; + let max_cmd_buf_sz = UblkQueue::cmd_buf_sz(sys::UBLK_MAX_QUEUE_DEPTH) as libc::off_t; ring.submitter() .register_files(&tgt.fds[0..tgt.nr_fds as usize])?; - let off = sys::UBLKSRV_CMD_BUF_OFFSET as libc::off_t - + q_id as libc::off_t - * ((sys::UBLK_MAX_QUEUE_DEPTH as usize - * core::mem::size_of::()) - as libc::off_t); + let off = + sys::UBLKSRV_CMD_BUF_OFFSET as libc::off_t + (q_id as libc::off_t) * max_cmd_buf_sz; let io_cmd_buf = unsafe { libc::mmap( std::ptr::null_mut::(),