Skip to content

Commit

Permalink
libublk: io: change buffer type to '*mut u8' in UblkQueue::submit_io_…
Browse files Browse the repository at this point in the history
…cmd()

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
  • Loading branch information
ming1 committed Oct 28, 2023
1 parent 07ac33d commit d63fa3d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ fn main() {
exe.spawn(tag, async move {
let mut cmd_op = libublk::sys::UBLK_IO_FETCH_REQ;
let mut result = 0;
let addr = std::ptr::null_mut();
loop {
if q.submit_io_cmd(tag, cmd_op, 0, result).await
if q.submit_io_cmd(tag, cmd_op, addr, result).await
== libublk::sys::UBLK_IO_RES_ABORT
{
break;
Expand All @@ -112,7 +113,6 @@ fn main() {
})
.unwrap();
}

```

With Rust async/.await, each io command is handled in one standalone io task.
Expand Down
2 changes: 1 addition & 1 deletion examples/loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ fn __test_add(
let q = q_rc.clone();

exe.spawn(tag as u16, async move {
let buf_addr = q.get_io_buf_addr(tag) as u64;
let buf_addr = q.get_io_buf_addr(tag);
let mut cmd_op = sys::UBLK_IO_FETCH_REQ;
let mut res = 0;
loop {
Expand Down
2 changes: 1 addition & 1 deletion examples/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn __test_add(id: i32, nr_queues: u32, depth: u32, ctrl_flags: u64, buf_size: u3
let mut cmd_op = libublk::sys::UBLK_IO_FETCH_REQ;
let mut res = 0;
loop {
let cmd_res = q.submit_io_cmd(tag, cmd_op, buf_addr as u64, res).await;
let cmd_res = q.submit_io_cmd(tag, cmd_op, buf_addr, res).await;
if cmd_res == libublk::sys::UBLK_IO_RES_ABORT {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/ramdisk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn rd_add_dev(dev_id: i32, buf_addr: u64, size: u64, for_add: bool) {
let mut res = 0;

loop {
let cmd_res = q.submit_io_cmd(tag, cmd_op, addr as u64, res).await;
let cmd_res = q.submit_io_cmd(tag, cmd_op, addr, res).await;
if cmd_res == libublk::sys::UBLK_IO_RES_ABORT {
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,12 +712,12 @@ impl UblkQueue<'_> {
&self,
tag: u16,
cmd_op: u32,
buf_addr: u64,
buf_addr: *mut u8,
result: i32,
) -> UringOpFuture {
let user_data = UblkIOCtx::build_user_data(tag, cmd_op, 0, false);

self.__submit_io_cmd(tag, cmd_op, buf_addr, user_data, result);
self.__submit_io_cmd(tag, cmd_op, buf_addr as u64, user_data, result);

UringOpFuture { user_data }
}
Expand Down
2 changes: 1 addition & 1 deletion tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ mod integration {
let buf = q.get_io_buf_addr(tag);
let mut res = 0;
loop {
let cmd_res = q.submit_io_cmd(tag, cmd_op, buf as u64, res).await;
let cmd_res = q.submit_io_cmd(tag, cmd_op, buf, res).await;
if cmd_res == sys::UBLK_IO_RES_ABORT {
break;
}
Expand Down

0 comments on commit d63fa3d

Please sign in to comment.