From 88a13852bf2d2c7976008e488ad37145f32e8406 Mon Sep 17 00:00:00 2001 From: Jiang Liu Date: Sun, 30 Apr 2023 17:10:00 +0800 Subject: [PATCH] rafs: avoid a debug_assert related to v5 amplify io A debug_assert() may get triggered by RAFS v5 amplify io related code, it's caused by a bug in RafsSuper::amplify_io(). Signed-off-by: Jiang Liu --- rafs/src/builder/core/v5.rs | 3 +-- rafs/src/metadata/md_v5.rs | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/rafs/src/builder/core/v5.rs b/rafs/src/builder/core/v5.rs index a357db0cc82..ddfc752aa5d 100644 --- a/rafs/src/builder/core/v5.rs +++ b/rafs/src/builder/core/v5.rs @@ -173,8 +173,7 @@ impl Bootstrap { // Set super block let mut super_block = RafsV5SuperBlock::new(); - let inodes_count = bootstrap_ctx.inode_map.len() as u64; - super_block.set_inodes_count(inodes_count); + super_block.set_inodes_count(inode_table_entries as u64); super_block.set_inode_table_offset(super_block_size as u64); super_block.set_inode_table_entries(inode_table_entries); super_block.set_blob_table_offset(blob_table_offset as u64); diff --git a/rafs/src/metadata/md_v5.rs b/rafs/src/metadata/md_v5.rs index 5964b35b603..5a17bd309bc 100644 --- a/rafs/src/metadata/md_v5.rs +++ b/rafs/src/metadata/md_v5.rs @@ -172,12 +172,12 @@ impl RafsSuper { if let Ok(ni) = self.get_inode(next_ino, false) { if ni.is_reg() { let next_size = ni.size(); - let next_size = if next_size < window_size { + let next_size = if next_size == 0 { + continue; + } else if next_size < window_size { next_size } else if window_size >= self.meta.chunk_size as u64 { window_size / self.meta.chunk_size as u64 * self.meta.chunk_size as u64 - } else if next_size == 0 { - continue; } else { break; };