Merge pull request #7799 from UiPath/clh-directio-support

clh: Direct IO support for block devices
This commit is contained in:
Jeremi Piotrowski 2023-09-21 19:16:08 +02:00 committed by GitHub
commit 28dd5ae91e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 6 deletions

View File

@ -176,6 +176,15 @@ virtio_fs_cache = "@DEFVIRTIOFSCACHE@"
# rootfs is backed by a block device. This is virtio-blk.
block_device_driver = "virtio-blk"
# Specifies cache-related options will be set to block devices or not.
# Default false
#block_device_cache_set = true
# Specifies cache-related options for block devices.
# Denotes whether use of O_DIRECT (bypass the host page cache) is enabled.
# Default false
#block_device_cache_direct = true
# Enable huge pages for VM RAM, default false
# Enabling this will result in the VM memory
# being allocated using huge pages.

View File

@ -126,11 +126,6 @@ block_device_driver = "@DEFBLOCKSTORAGEDRIVER_FC@"
# Default false
#block_device_cache_set = true
# Specifies cache-related options for block devices.
# Denotes whether use of O_DIRECT (bypass the host page cache) is enabled.
# Default false
#block_device_cache_direct = true
# Specifies cache-related options for block devices.
# Denotes whether flush requests for the device are ignored.
# Default false

View File

@ -1082,7 +1082,6 @@ func newClhHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
BlockDeviceDriver: blockDriver,
BlockDeviceCacheSet: h.BlockDeviceCacheSet,
BlockDeviceCacheDirect: h.BlockDeviceCacheDirect,
BlockDeviceCacheNoflush: h.BlockDeviceCacheNoflush,
EnableIOThreads: h.EnableIOThreads,
Msize9p: h.msize9p(),
ColdPlugVFIO: h.coldPlugVFIO(),

View File

@ -851,6 +851,9 @@ func (clh *cloudHypervisor) hotplugAddBlockDevice(drive *config.BlockDrive) erro
clhDisk := *chclient.NewDiskConfig(drive.File)
clhDisk.Readonly = &drive.ReadOnly
clhDisk.VhostUser = func(b bool) *bool { return &b }(false)
if clh.config.BlockDeviceCacheSet {
clhDisk.Direct = &clh.config.BlockDeviceCacheDirect
}
queues := int32(clh.config.NumVCPUs)
queueSize := int32(1024)

View File

@ -835,6 +835,17 @@ func (fc *firecracker) createDiskPool(ctx context.Context) error {
PathOnHost: &jailedDrive,
}
if fc.config.BlockDeviceCacheSet {
var cacheOption string
if fc.config.BlockDeviceCacheNoflush {
cacheOption = models.DriveCacheTypeUnsafe
} else {
cacheOption = models.DriveCacheTypeWriteback
}
drive.CacheType = &cacheOption
}
fc.fcConfig.Drives = append(fc.fcConfig.Drives, drive)
}