From 588b458268201bc6b3ad46812b49e37a1634cc3a Mon Sep 17 00:00:00 2001 From: Shaowei Song <1498430017@qq.com> Date: Thu, 3 Nov 2022 11:07:18 +0800 Subject: [PATCH] [sefs] Configure larger cache size to improve pfs performance --- src/libos/src/fs/sefs/mod.rs | 4 ++++ src/libos/src/fs/sefs/sgx_storage.rs | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/libos/src/fs/sefs/mod.rs b/src/libos/src/fs/sefs/mod.rs index 463278df..67fd54f6 100644 --- a/src/libos/src/fs/sefs/mod.rs +++ b/src/libos/src/fs/sefs/mod.rs @@ -5,3 +5,7 @@ pub use self::sgx_uuid_provider::SgxUuidProvider; mod sgx_storage; mod sgx_uuid_provider; + +// Cache size of underlying SGX-PFS of SEFS +// Default cache size: 0x1000 * 48 +const SEFS_CACHE_SIZE: u64 = 0x1000 * 256; diff --git a/src/libos/src/fs/sefs/sgx_storage.rs b/src/libos/src/fs/sefs/sgx_storage.rs index d74aebb1..cd63d54b 100644 --- a/src/libos/src/fs/sefs/sgx_storage.rs +++ b/src/libos/src/fs/sefs/sgx_storage.rs @@ -97,9 +97,11 @@ impl Storage for SgxStorage { let file = match self.encrypt_mode { EncryptMode::IntegrityOnly(_) => options.open_integrity_only(path)?, EncryptMode::EncryptWithIntegrity(key, _) | EncryptMode::Encrypt(key) => { - options.open_ex(path, &key)? + options.open_with(path, Some(&key), Some(SEFS_CACHE_SIZE))? + } + EncryptMode::EncryptAutoKey => { + options.open_with(path, None, Some(SEFS_CACHE_SIZE))? } - EncryptMode::EncryptAutoKey => options.open(path)?, }; // Check the MAC of the root file against the given root MAC of the storage @@ -132,9 +134,11 @@ impl Storage for SgxStorage { let file = match self.encrypt_mode { EncryptMode::IntegrityOnly(_) => options.open_integrity_only(path)?, EncryptMode::EncryptWithIntegrity(key, _) | EncryptMode::Encrypt(key) => { - options.open_ex(path, &key)? + options.open_with(path, Some(&key), Some(SEFS_CACHE_SIZE))? + } + EncryptMode::EncryptAutoKey => { + options.open_with(path, None, Some(SEFS_CACHE_SIZE))? } - EncryptMode::EncryptAutoKey => options.open(path)?, }; Ok(LockedFile(Arc::new(Mutex::new(file)))) })?;