From 332f3dd4561019546598b06b8092a3d2f45e8786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B3=B0=E5=8F=8B?= Date: Thu, 1 Feb 2024 08:44:34 +0000 Subject: [PATCH] fix: compatibility to image without ext table for blob cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are scenes that cache file is smaller than expect size. Such as: 1. Nydusd 1.6 generates cache file by prefetch, which is smaller than size in boot. 2. Nydusd 2.2 generates cache file by prefetch, when image not provide ext blob tables. 3. Nydusd not have enough time to fill cache for blob. Equality check for size is too much strict for both 1.6 compatibility and 2.2 concurrency. This pr ensures blob size smaller or equal than expect size. It also truncates blob cache when smaller than expect size. Signed-off-by: 泰友 --- storage/src/cache/filecache/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/src/cache/filecache/mod.rs b/storage/src/cache/filecache/mod.rs index 1e38f3b3072..fd561c8a60c 100644 --- a/storage/src/cache/filecache/mod.rs +++ b/storage/src/cache/filecache/mod.rs @@ -257,7 +257,7 @@ impl FileCacheEntry { } else { blob_info.uncompressed_size() }; - if file_size == 0 { + if file_size == 0 || file_size < cached_file_size { file.set_len(cached_file_size)?; } else if cached_file_size != 0 && file_size != cached_file_size { let msg = format!(