mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block_util: Preserve ordering of sync file backend completions
For the synchronous backends efficiently preserve the order for completion requests through the use of VecDequeue. Preserving the order is not required but is beneficial as it matches the existing optimisation that looks to match completions and requests. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
use crate::async_io::{AsyncIo, AsyncIoResult, DiskFile, DiskFileError, DiskFileResult};
|
||||
use crate::AsyncAdaptor;
|
||||
use qcow::{QcowFile, RawFile, Result as QcowResult};
|
||||
use std::collections::VecDeque;
|
||||
use std::fs::File;
|
||||
use std::io::{Seek, SeekFrom};
|
||||
use std::sync::{Arc, Mutex, MutexGuard};
|
||||
@@ -37,7 +38,7 @@ impl DiskFile for QcowDiskSync {
|
||||
pub struct QcowSync {
|
||||
qcow_file: Arc<Mutex<QcowFile>>,
|
||||
eventfd: EventFd,
|
||||
completion_list: Vec<(u64, i32)>,
|
||||
completion_list: VecDeque<(u64, i32)>,
|
||||
}
|
||||
|
||||
impl QcowSync {
|
||||
@@ -46,7 +47,7 @@ impl QcowSync {
|
||||
qcow_file,
|
||||
eventfd: EventFd::new(libc::EFD_NONBLOCK)
|
||||
.expect("Failed creating EventFd for QcowSync"),
|
||||
completion_list: Vec::new(),
|
||||
completion_list: VecDeque::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,6 +99,6 @@ impl AsyncIo for QcowSync {
|
||||
}
|
||||
|
||||
fn next_completed_request(&mut self) -> Option<(u64, i32)> {
|
||||
self.completion_list.pop()
|
||||
self.completion_list.pop_front()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user