mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 19:32:20 +00:00
block_util: Ensure all io_uring operations are asynchronous
Some operations complete directly after they have been submitted, which means they are not submitted asynchronously and therefore they don't generate any ioevent. This is the reason why we are not processing some of the completed operations, which leads to some unpredictable behaviors. Forcing all io_uring operations submitted to the SQE to be asynchronous helps simplifying the code as it ensures the completion of every operation will generate an ioevent, therefore no operation is missed. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
144f0839ae
commit
b8bbe244b7
@ -14,7 +14,7 @@ extern crate log;
|
||||
extern crate serde_derive;
|
||||
|
||||
#[cfg(feature = "io_uring")]
|
||||
use io_uring::{opcode, IoUring, Probe};
|
||||
use io_uring::{opcode, squeue, IoUring, Probe};
|
||||
use serde::ser::{Serialize, SerializeStruct, Serializer};
|
||||
use std::cmp;
|
||||
use std::io::{self, Read, Seek, SeekFrom, Write};
|
||||
@ -278,7 +278,7 @@ impl Request {
|
||||
) -> result::Result<bool, ExecuteError> {
|
||||
let sector = self.sector;
|
||||
let request_type = self.request_type;
|
||||
let offset = (sector as i64) << SECTOR_SHIFT;
|
||||
let offset = (sector << SECTOR_SHIFT) as libc::off_t;
|
||||
|
||||
let (submitter, sq, _) = io_uring.split();
|
||||
let mut avail_sq = sq.available();
|
||||
@ -321,6 +321,7 @@ impl Request {
|
||||
)
|
||||
.offset(offset)
|
||||
.build()
|
||||
.flags(squeue::Flags::ASYNC)
|
||||
.user_data(user_data),
|
||||
)
|
||||
};
|
||||
@ -337,6 +338,7 @@ impl Request {
|
||||
)
|
||||
.offset(offset)
|
||||
.build()
|
||||
.flags(squeue::Flags::ASYNC)
|
||||
.user_data(user_data),
|
||||
)
|
||||
};
|
||||
@ -347,6 +349,7 @@ impl Request {
|
||||
avail_sq.push(
|
||||
opcode::Fsync::new(opcode::types::Fd(disk_image_fd))
|
||||
.build()
|
||||
.flags(squeue::Flags::ASYNC)
|
||||
.user_data(user_data),
|
||||
)
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user