You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there an example of how to properly create and run multiple block devices in a single process? The recommended run_target only accepts one device and dedicates the current thread for that device. I tried running run_target in multiple threads simultaneously, but that seems to invoke some sort of race condition, which causes all threads to block on starting the handler and never create the device. Adding delay between these threads seem to resolve the problem, but obviously that shouldn't be the proper way to do it.
The text was updated successfully, but these errors were encountered:
There isn't such example yet, and this feature is planned to
be supported in 0.3 by converting control commands into
async/await.
However you still can do that with current interfaces, and please refer to examples/ramdisk.rs, in which one ublk device
is created, such as:
start one device:
let (mut ctrl, dev) = sess.create_devices();
ctrl.configure_queue(&dev, 0, unsafe { libc::gettid() })
let (token, buf) = ctrl.submit_start_dev(&dev).unwrap();
let res = loop {
let _ = q_rc.flush_and_wake_io_tasks(&exe, 0);
let _res = ctrl.poll_start_dev(token);
...
};
repeat the above logic for N devices in current process
run epoll() on all queue's ring FD, and once there is an
event coming, call q_rc.flush_and_wake_io_tasks(exe, 0) for this queue.
The drawback is that you have to start device one by one.
Once control command is converted to async/await, multiple
devices can be supported concurrently in single task. And in
future, shared (both control and data) uring will be supported too for creating N devices in single task.
Is there an example of how to properly create and run multiple block devices in a single process? The recommended
run_target
only accepts one device and dedicates the current thread for that device. I tried runningrun_target
in multiple threads simultaneously, but that seems to invoke some sort of race condition, which causes all threads to block on starting the handler and never create the device. Adding delay between these threads seem to resolve the problem, but obviously that shouldn't be the proper way to do it.The text was updated successfully, but these errors were encountered: