Skip to content

Commit

Permalink
fix: compatibility to image without ext table for blob cache
Browse files Browse the repository at this point in the history
    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]>
  • Loading branch information
泰友 authored and imeoer committed Jun 18, 2024
1 parent 7cf2d4a commit 332f3dd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion storage/src/cache/filecache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down

0 comments on commit 332f3dd

Please sign in to comment.