Skip to content

Commit

Permalink
storage: rename some blob feature names
Browse files Browse the repository at this point in the history
Rename some blob feature names.

Signed-off-by: Jiang Liu <[email protected]>
  • Loading branch information
jiangliu committed Dec 29, 2022
1 parent e0cfa20 commit 79bc029
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions rafs/src/metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ impl RafsSuper {
let blobs = rs.superblock.get_blob_infos();
for blob in blobs.iter() {
// Fix blob id for new images with old converters.
if blob.has_feature(BlobFeatures::INLINED_META) {
if blob.has_feature(BlobFeatures::INLINED_FS_META) {
blob.set_blob_id_from_meta_path(path.as_ref())?;
fixed = true;
}
Expand All @@ -702,7 +702,7 @@ impl RafsSuper {
// Fix blob id for old images with old converters.
let last = blobs.len() - 1;
let blob = &blobs[last];
if !blob.has_feature(BlobFeatures::CAP_INLINED_META) {
if !blob.has_feature(BlobFeatures::CAP_TAR_TOC) {
rs.set_blob_id_from_meta_path(path.as_ref())?;
}
}
Expand Down Expand Up @@ -738,8 +738,8 @@ impl RafsSuper {
pub fn set_blob_id_from_meta_path(&self, meta_path: &Path) -> Result<()> {
let blobs = self.superblock.get_blob_infos();
for blob in blobs.iter() {
if blob.has_feature(BlobFeatures::INLINED_META)
|| !blob.has_feature(BlobFeatures::CAP_INLINED_META)
if blob.has_feature(BlobFeatures::INLINED_FS_META)
|| !blob.has_feature(BlobFeatures::CAP_TAR_TOC)
{
blob.set_blob_id_from_meta_path(meta_path)?;
}
Expand Down
16 changes: 7 additions & 9 deletions src/bin/nydus-image/core/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ impl BlobContext {
.set_4k_aligned(features.contains(BlobFeatures::ALIGNED));
blob_ctx
.blob_meta_header
.set_inlined_meta(features.contains(BlobFeatures::INLINED_META));
.set_inlined_fs_meta(features.contains(BlobFeatures::INLINED_FS_META));
blob_ctx
.blob_meta_header
.set_chunk_info_v2(features.contains(BlobFeatures::CHUNK_INFO_V2));
Expand All @@ -461,7 +461,7 @@ impl BlobContext {
.set_inlined_chunk_digest(features.contains(BlobFeatures::INLINED_CHUNK_DIGEST));
blob_ctx
.blob_meta_header
.set_cap_inlined_meta(features.contains(BlobFeatures::CAP_INLINED_META));
.set_cap_tar_toc(features.contains(BlobFeatures::CAP_TAR_TOC));

blob_ctx
}
Expand All @@ -477,8 +477,8 @@ impl BlobContext {

// Fixes up blob info objects from inlined-meta blobs.
if chunk_source == ChunkSource::Dict || chunk_source == ChunkSource::Parent {
if features.contains(BlobFeatures::INLINED_META) {
features &= !BlobFeatures::INLINED_META;
if features.contains(BlobFeatures::INLINED_FS_META) {
features &= !BlobFeatures::INLINED_FS_META;

if !features.contains(BlobFeatures::ZRAN) {
blob_id = blob.blob_id();
Expand Down Expand Up @@ -538,9 +538,7 @@ impl BlobContext {
}
}
}
} else if !blob.has_feature(BlobFeatures::CAP_INLINED_META)
&& !ctx.can_access_data_blobs
{
} else if !blob.has_feature(BlobFeatures::CAP_TAR_TOC) && !ctx.can_access_data_blobs {
blob_id = blob.blob_id();
}
}
Expand Down Expand Up @@ -1070,9 +1068,9 @@ impl BuildContext {
features: Features,
) -> Self {
let blob_features = if blob_inline_meta {
BlobFeatures::INLINED_META | BlobFeatures::CAP_INLINED_META
BlobFeatures::INLINED_FS_META | BlobFeatures::CAP_TAR_TOC
} else {
BlobFeatures::CAP_INLINED_META
BlobFeatures::CAP_TAR_TOC
};
BuildContext {
blob_id,
Expand Down
14 changes: 8 additions & 6 deletions storage/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ bitflags! {
/// Uncompressed chunk data is 4K aligned.
const ALIGNED = 0x0000_0001;
/// RAFS meta data is inlined in the data blob.
const INLINED_META = 0x0000_0002;
const INLINED_FS_META = 0x0000_0002;
/// Blob chunk information format v2.
const CHUNK_INFO_V2 = 0x0000_0004;
/// Blob compression information data include context data for zlib random access.
const ZRAN = 0x0000_0008;
/// Chunk digest array is inlined in the data blob.
const INLINED_CHUNK_DIGEST = 0x0000_0010;
/// Inlined-meta capability, used to support backward compatibility for legacy converters.
const CAP_INLINED_META = 0x4000_0000;
/// Data blob are encoded with Tar header and optionally ToC.
/// It's also a flag indicating that images are generated with `nydus-image` v2.2 or newer.
const CAP_TAR_TOC = 0x4000_0000;
/// Rafs V5 image without extended blob table, this is an internal flag.
const _V5_NO_EXT_BLOB_TABLE = 0x8000_0000;
}
Expand Down Expand Up @@ -198,8 +199,9 @@ impl BlobInfo {

/// Get the id of the blob, with special handling of `inlined-meta` case.
pub fn blob_id(&self) -> String {
if (self.has_feature(BlobFeatures::INLINED_META) && !self.has_feature(BlobFeatures::ZRAN))
|| !self.has_feature(BlobFeatures::CAP_INLINED_META)
if (self.has_feature(BlobFeatures::INLINED_FS_META)
&& !self.has_feature(BlobFeatures::ZRAN))
|| !self.has_feature(BlobFeatures::CAP_TAR_TOC)
{
let guard = self.meta_path.lock().unwrap();
if !guard.is_empty() {
Expand Down Expand Up @@ -453,7 +455,7 @@ impl BlobInfo {
/// Get RAFS blob id for ZRan.
pub fn get_rafs_blob_id(&self) -> Result<String, Error> {
assert!(self.has_feature(BlobFeatures::ZRAN));
let id = if self.has_feature(BlobFeatures::INLINED_META) {
let id = if self.has_feature(BlobFeatures::INLINED_FS_META) {
let guard = self.meta_path.lock().unwrap();
if guard.is_empty() {
return Err(einval!("failed to get blob id from meta file name"));
Expand Down
18 changes: 9 additions & 9 deletions storage/src/meta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ impl BlobMetaHeaderOndisk {
}

/// Set flag indicating whether RAFS meta is inlined in the data blob.
pub fn set_inlined_meta(&mut self, inlined: bool) {
pub fn set_inlined_fs_meta(&mut self, inlined: bool) {
if inlined {
self.s_features |= BlobFeatures::INLINED_META.bits();
self.s_features |= BlobFeatures::INLINED_FS_META.bits();
} else {
self.s_features &= !BlobFeatures::INLINED_META.bits();
self.s_features &= !BlobFeatures::INLINED_FS_META.bits();
}
}

Expand Down Expand Up @@ -283,11 +283,11 @@ impl BlobMetaHeaderOndisk {
}

/// Set flag indicating having inlined-meta capability.
pub fn set_cap_inlined_meta(&mut self, enable: bool) {
pub fn set_cap_tar_toc(&mut self, enable: bool) {
if enable {
self.s_features |= BlobFeatures::CAP_INLINED_META.bits();
self.s_features |= BlobFeatures::CAP_TAR_TOC.bits();
} else {
self.s_features &= !BlobFeatures::CAP_INLINED_META.bits();
self.s_features &= !BlobFeatures::CAP_TAR_TOC.bits();
}
}

Expand Down Expand Up @@ -1660,7 +1660,7 @@ pub(crate) mod tests {
let path = PathBuf::from(root_dir).join("../tests/texture/zran/233c72f2b6b698c07021c4da367cfe2dff4f049efbaa885ca0ff760ea297865a");

let features = BlobFeatures::ALIGNED
| BlobFeatures::INLINED_META
| BlobFeatures::INLINED_FS_META
| BlobFeatures::CHUNK_INFO_V2
| BlobFeatures::ZRAN;
let mut blob_info = BlobInfo::new(
Expand Down Expand Up @@ -1713,7 +1713,7 @@ pub(crate) mod tests {
let path = PathBuf::from(root_dir).join("../tests/texture/zran/233c72f2b6b698c07021c4da367cfe2dff4f049efbaa885ca0ff760ea297865a");

let features = BlobFeatures::ALIGNED
| BlobFeatures::INLINED_META
| BlobFeatures::INLINED_FS_META
| BlobFeatures::CHUNK_INFO_V2
| BlobFeatures::ZRAN;
let mut blob_info = BlobInfo::new(
Expand Down Expand Up @@ -1770,7 +1770,7 @@ pub(crate) mod tests {
let path = PathBuf::from(root_dir).join("../tests/texture/zran/233c72f2b6b698c07021c4da367cfe2dff4f049efbaa885ca0ff760ea297865a");

let features = BlobFeatures::ALIGNED
| BlobFeatures::INLINED_META
| BlobFeatures::INLINED_FS_META
| BlobFeatures::CHUNK_INFO_V2
| BlobFeatures::ZRAN;
let mut blob_info = BlobInfo::new(
Expand Down

0 comments on commit 79bc029

Please sign in to comment.