From d507d189bbfda69a26b2e1664e2b3428dbfe90ca Mon Sep 17 00:00:00 2001 From: Alexandru Matei Date: Fri, 1 Sep 2023 12:49:18 +0300 Subject: [PATCH] fc: Add support for noflush cache option Firecracker supports noflush semantic via Unsafe cache type. There is no support for direct i/o, remove it from config file Fixes: #7823 Signed-off-by: Alexandru Matei --- src/runtime/config/configuration-fc.toml.in | 5 ----- src/runtime/virtcontainers/fc.go | 11 +++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/runtime/config/configuration-fc.toml.in b/src/runtime/config/configuration-fc.toml.in index e28316cfad..28040aacc1 100644 --- a/src/runtime/config/configuration-fc.toml.in +++ b/src/runtime/config/configuration-fc.toml.in @@ -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 diff --git a/src/runtime/virtcontainers/fc.go b/src/runtime/virtcontainers/fc.go index e3348f68dd..1ecf366b4f 100644 --- a/src/runtime/virtcontainers/fc.go +++ b/src/runtime/virtcontainers/fc.go @@ -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) }