Skip to content

Commit f4fde1c

Browse files
author
泰友
committed
fix: compatibility to image without ext table for blob cache
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: 泰友 <[email protected]>
1 parent 2a8ae3f commit f4fde1c

File tree

1 file changed

+1
-1
lines changed
  • storage/src/cache/filecache

1 file changed

+1
-1
lines changed

storage/src/cache/filecache/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl FileCacheEntry {
257257
} else {
258258
blob_info.uncompressed_size()
259259
};
260-
if file_size == 0 {
260+
if file_size == 0 || file_size < cached_file_size {
261261
file.set_len(cached_file_size)?;
262262
} else if cached_file_size != 0 && file_size != cached_file_size {
263263
let msg = format!(

0 commit comments

Comments
 (0)