Skip to content

Commit

Permalink
Merge pull request #1003 from jiangliu/prefetch-warn
Browse files Browse the repository at this point in the history
storage: add BlobFeature::HAS_TAR_HEADER to calcalute
  • Loading branch information
imeoer authored Jan 14, 2023
2 parents 3805773 + 7e0f901 commit 07d2c7a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/bin/nydus-image/core/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ impl BlobContext {
blob_ctx
.blob_meta_header
.set_inlined_chunk_digest(features.contains(BlobFeatures::INLINED_CHUNK_DIGEST));
blob_ctx
.blob_meta_header
.set_has_tar_header(features.contains(BlobFeatures::HAS_TAR_HEADER));
blob_ctx
.blob_meta_header
.set_has_toc(features.contains(BlobFeatures::HAS_TOC));
Expand Down Expand Up @@ -1080,9 +1083,11 @@ impl BuildContext {
let mut blob_features = BlobFeatures::CAP_TAR_TOC;
if blob_inline_meta {
blob_features |= BlobFeatures::INLINED_FS_META;
blob_features |= BlobFeatures::HAS_TAR_HEADER;
};
if features.is_enabled(Feature::BlobToc) {
blob_features |= BlobFeatures::HAS_TOC;
blob_features |= BlobFeatures::HAS_TAR_HEADER;
}

BuildContext {
Expand Down
10 changes: 5 additions & 5 deletions storage/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ bitflags! {
const SEPARATE = 0x0000_0010;
/// Chunk digest array is inlined in the data blob.
const INLINED_CHUNK_DIGEST = 0x0000_0020;
/// Blob has TAR headers to separate contents.
const HAS_TAR_HEADER = 0x1000_0000;
/// Blob has Table of Content (ToC) at the tail.
const HAS_TOC = 0x2000_0000;
/// Data blob are encoded with Tar header and optionally ToC.
Expand Down Expand Up @@ -229,18 +231,16 @@ impl BlobInfo {
// Image built with nydus 2.2 and newer versions.
if self.meta_ci_is_valid() {
// For RAFS v6
if self.has_feature(BlobFeatures::HAS_TOC)
|| self.has_feature(BlobFeatures::INLINED_FS_META)
{
if self.has_feature(BlobFeatures::HAS_TAR_HEADER) {
// There's a tar header between chunk data and compression information.
self.meta_ci_offset - 0x200
} else {
self.meta_ci_offset
}
} else {
// For RAFS v5
if self.has_feature(BlobFeatures::INLINED_FS_META) {
// There's a tar header between chunk data and compression information.
if self.has_feature(BlobFeatures::HAS_TAR_HEADER) {
// There's a tar header between chunk data and fs meta data.
self.compressed_size - 0x200
} else {
self.compressed_size
Expand Down
19 changes: 17 additions & 2 deletions storage/src/meta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,16 @@ impl BlobCompressionContextHeader {
}
}

/// Set flag indicating new blob format with tar/toc headers.
/// Set flag indicating new blob format with tar headers.
pub fn set_has_tar_header(&mut self, enable: bool) {
if enable {
self.s_features |= BlobFeatures::HAS_TAR_HEADER.bits();
} else {
self.s_features &= !BlobFeatures::HAS_TAR_HEADER.bits();
}
}

/// Set flag indicating new blob format with toc headers.
pub fn set_has_toc(&mut self, enable: bool) {
if enable {
self.s_features |= BlobFeatures::HAS_TOC.bits();
Expand Down Expand Up @@ -1646,7 +1655,10 @@ pub trait BlobMetaChunkInfo {
pub fn format_blob_features(features: BlobFeatures) -> String {
let mut output = String::new();
if features.contains(BlobFeatures::ALIGNED) {
output += "4K-align ";
output += "aligned ";
}
if features.contains(BlobFeatures::CAP_TAR_TOC) {
output += "cap_toc ";
}
if features.contains(BlobFeatures::INLINED_CHUNK_DIGEST) {
output += "chunk-digest ";
Expand All @@ -1660,6 +1672,9 @@ pub fn format_blob_features(features: BlobFeatures) -> String {
if features.contains(BlobFeatures::SEPARATE) {
output += "separate ";
}
if features.contains(BlobFeatures::HAS_TAR_HEADER) {
output += "tar-header ";
}
if features.contains(BlobFeatures::HAS_TOC) {
output += "toc ";
}
Expand Down

0 comments on commit 07d2c7a

Please sign in to comment.