From b7f8af04f6fce35406c87d7b14f1aa2c5ea52840 Mon Sep 17 00:00:00 2001 From: Jiang Liu Date: Thu, 30 Mar 2023 13:31:17 +0800 Subject: [PATCH 1/2] rafs: fix a incorrect mapped_blkaddr for multi layer images When generating a RAFS filesystem with multiple data blobs, the mapped_blkaddr for second and following-on blobs are incorrect. Signed-off-by: Jiang Liu --- rafs/src/builder/core/v6.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rafs/src/builder/core/v6.rs b/rafs/src/builder/core/v6.rs index 2a9fc803648..f0794f003a5 100644 --- a/rafs/src/builder/core/v6.rs +++ b/rafs/src/builder/core/v6.rs @@ -764,7 +764,7 @@ impl Bootstrap { "blob id length is bigger than 64 bytes, blob id {:?}", entry.blob_id() )); - } else if entry.uncompressed_size() / ctx.v6_block_size() > u32::MAX as u64 { + } else if entry.uncompressed_size() / block_size > u32::MAX as u64 { bail!(format!( "uncompressed blob size (0x:{:x}) is too big", entry.uncompressed_size() @@ -773,12 +773,12 @@ impl Bootstrap { if !entry.has_feature(BlobFeatures::INLINED_CHUNK_DIGEST) { inlined_chunk_digest = false; } - let cnt = (entry.uncompressed_size() / ctx.v6_block_size()) as u32; + let cnt = (entry.uncompressed_size() / block_size) as u32; if block_count.checked_add(cnt).is_none() { - bail!("Too many data blocks in RAFS filesystem, block size 0x{:x}, block count 0x{:x}", ctx.v6_block_size(), block_count as u64 + cnt as u64); + bail!("Too many data blocks in RAFS filesystem, block size 0x{:x}, block count 0x{:x}", block_size, block_count as u64 + cnt as u64); } let mapped_blkaddr = Self::v6_align_mapped_blkaddr(block_size, pos)?; - pos += cnt as u64 * ctx.v6_block_size(); + pos = (mapped_blkaddr + cnt) as u64 * block_size; block_count += cnt; let id = entry.blob_id(); From 4dd44255fffa08ce21db32d59dde208ebec86bc8 Mon Sep 17 00:00:00 2001 From: Jiang Liu Date: Thu, 30 Mar 2023 13:43:34 +0800 Subject: [PATCH 2/2] rafs: change alignment for v6 mapped_blkaddr from 2M to 512K Change alignment for v6 mapped_blkaddr from 2M to 512K, 512K is enough to support dm-verity. Signed-off-by: Jiang Liu --- rafs/src/builder/core/v6.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rafs/src/builder/core/v6.rs b/rafs/src/builder/core/v6.rs index f0794f003a5..37409826c19 100644 --- a/rafs/src/builder/core/v6.rs +++ b/rafs/src/builder/core/v6.rs @@ -29,7 +29,7 @@ use crate::metadata::RafsStore; use crate::RafsIoWrite; const WRITE_PADDING_DATA: [u8; 4096] = [0u8; 4096]; -const V6_BLOCK_SEG_ALIGNMENT: u64 = 0x20_0000; +const V6_BLOCK_SEG_ALIGNMENT: u64 = 0x8_0000; // Rafs v6 dedicated methods impl Node {