mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: io: Rename SyncCompletionQueue to CompletionCommon
The Sync prefix is too narrow because the queue is not tied to synchronous execution. Rename it to CompletionCommon, following the Common suffix the codebase already uses for shared helper types such as VirtioCommon. The queue holds no engine specific state, so it can be reused more widely across backends. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
5e01807fa2
commit
636d8a83ca
@@ -19,7 +19,7 @@ use super::metadata::{
|
||||
};
|
||||
use super::qcow_raw_file::QcowRawFile;
|
||||
use crate::async_io::{
|
||||
AsyncIo, AsyncIoCompletion, AsyncIoError, AsyncIoOperation, AsyncIoResult, SyncCompletionQueue,
|
||||
AsyncIo, AsyncIoCompletion, AsyncIoError, AsyncIoOperation, AsyncIoResult, CompletionCommon,
|
||||
};
|
||||
|
||||
pub(super) struct QcowSync {
|
||||
@@ -30,7 +30,7 @@ pub(super) struct QcowSync {
|
||||
sparse: bool,
|
||||
cluster_size: u64,
|
||||
decoder: Arc<dyn Decoder>,
|
||||
completions: SyncCompletionQueue,
|
||||
completions: CompletionCommon,
|
||||
}
|
||||
|
||||
impl QcowSync {
|
||||
@@ -47,7 +47,7 @@ impl QcowSync {
|
||||
data_file,
|
||||
backing_file,
|
||||
sparse,
|
||||
completions: SyncCompletionQueue::new(),
|
||||
completions: CompletionCommon::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ use std::os::unix::io::AsRawFd;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
use crate::async_io::{
|
||||
AsyncIo, AsyncIoCompletion, AsyncIoError, AsyncIoOperation, AsyncIoResult, SyncCompletionQueue,
|
||||
AsyncIo, AsyncIoCompletion, AsyncIoError, AsyncIoOperation, AsyncIoResult, CompletionCommon,
|
||||
};
|
||||
use crate::sparse::{punch_hole, write_zeroes};
|
||||
use crate::{AlignedFile, is_block_device};
|
||||
|
||||
pub(crate) struct RawSync {
|
||||
raw_file: AlignedFile,
|
||||
completions: SyncCompletionQueue,
|
||||
completions: CompletionCommon,
|
||||
alignment: u64,
|
||||
is_block_device: bool,
|
||||
}
|
||||
@@ -28,7 +28,7 @@ impl RawSync {
|
||||
let alignment = raw_file.alignment() as u64;
|
||||
RawSync {
|
||||
raw_file,
|
||||
completions: SyncCompletionQueue::new(),
|
||||
completions: CompletionCommon::new(),
|
||||
alignment,
|
||||
is_block_device,
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ use std::sync::{Arc, Mutex};
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
use crate::async_io::{
|
||||
AsyncIo, AsyncIoCompletion, AsyncIoError, AsyncIoOperation, AsyncIoResult, SyncCompletionQueue,
|
||||
AsyncIo, AsyncIoCompletion, AsyncIoError, AsyncIoOperation, AsyncIoResult, CompletionCommon,
|
||||
};
|
||||
use crate::formats::vhdx::Vhdx;
|
||||
|
||||
pub(super) struct VhdxSync {
|
||||
vhdx_file: Arc<Mutex<Vhdx>>,
|
||||
completions: SyncCompletionQueue,
|
||||
completions: CompletionCommon,
|
||||
size: u64,
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ impl VhdxSync {
|
||||
pub(super) fn new(vhdx_file: Arc<Mutex<Vhdx>>, size: u64) -> Self {
|
||||
VhdxSync {
|
||||
vhdx_file,
|
||||
completions: SyncCompletionQueue::new(),
|
||||
completions: CompletionCommon::new(),
|
||||
size,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ use std::{io, result};
|
||||
|
||||
pub use aio_data_io::AioDataIo;
|
||||
pub use completion::AsyncIoCompletion;
|
||||
pub(crate) use completion::SyncCompletionQueue;
|
||||
pub(crate) use completion::CompletionCommon;
|
||||
pub use guest_memory_target::GuestMemoryTarget;
|
||||
pub use operation::AsyncIoOperation;
|
||||
pub use owned_io_buffer::OwnedIoBuffer;
|
||||
|
||||
@@ -48,17 +48,17 @@ impl AsyncIoCompletion {
|
||||
/// Pending completions plus the eventfd that signals the device to
|
||||
/// drain them. Sync engines run each operation inline, enqueue its
|
||||
/// completion, and signal the eventfd.
|
||||
pub(crate) struct SyncCompletionQueue {
|
||||
pub(crate) struct CompletionCommon {
|
||||
queue: VecDeque<AsyncIoCompletion>,
|
||||
eventfd: EventFd,
|
||||
}
|
||||
|
||||
impl SyncCompletionQueue {
|
||||
impl CompletionCommon {
|
||||
pub(crate) fn new() -> Self {
|
||||
Self {
|
||||
queue: VecDeque::new(),
|
||||
eventfd: EventFd::new(libc::EFD_NONBLOCK)
|
||||
.expect("Failed creating EventFd for sync completion queue"),
|
||||
.expect("Failed creating EventFd for the completion queue"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user