mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: raw: Implement disk preallocation for sparse=false
When sparse=false is configured, preallocate the entire raw disk file at startup using fallocate(). This provides space reservation and reduces fragmentation. Only applies to raw disks. QCOW2/VHD/VHDX formats manage their own allocation. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
0a287793df
commit
49a30cbbaf
@@ -39,7 +39,8 @@ use block::raw_async_aio::RawFileDiskAio;
|
||||
use block::raw_sync::RawFileDiskSync;
|
||||
use block::vhdx_sync::VhdxDiskSync;
|
||||
use block::{
|
||||
ImageType, block_aio_is_supported, block_io_uring_is_supported, detect_image_type, qcow, vhdx,
|
||||
ImageType, block_aio_is_supported, block_io_uring_is_supported, detect_image_type,
|
||||
preallocate_disk, qcow, vhdx,
|
||||
};
|
||||
#[cfg(feature = "io_uring")]
|
||||
use block::{fixed_vhd_async::FixedVhdDiskAsync, raw_async::RawFileDisk};
|
||||
@@ -2699,6 +2700,14 @@ impl DeviceManager {
|
||||
}
|
||||
}
|
||||
ImageType::Raw => {
|
||||
// For non-sparse RAW disks, preallocate disk space
|
||||
if !disk_cfg.readonly
|
||||
&& !disk_cfg.sparse
|
||||
&& let Some(path) = &disk_cfg.path
|
||||
{
|
||||
preallocate_disk(&file, path);
|
||||
}
|
||||
|
||||
// Use asynchronous backend relying on io_uring if the
|
||||
// syscalls are supported.
|
||||
if cfg!(feature = "io_uring")
|
||||
|
||||
Reference in New Issue
Block a user