Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nydusify & nydus-image: v6 image conversion support #473

Merged
merged 21 commits into from
Jun 10, 2022
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d6e0a95
nydus-image: bug fix for `dirents_offset` overflow for non-dir/non-sy…
yawqi Jun 2, 2022
282cd91
nydus-image: feature, begin adding support for v6 image multi layer b…
yawqi Jun 2, 2022
c0f6d41
nydus-image: feature, implement interfaces for v6 OndiskInodeWrapper
yawqi Jun 2, 2022
9228759
nydus-image: feature, v6 multi layer build suppot
yawqi Jun 2, 2022
1244ac6
nydus-image: bug fix, correct implementation of chunk info for v6
zyfjeff Jun 6, 2022
4a0a6d2
nydus-image: bug fix, fix . and .. 's incorrent dirent order
zyfjeff Jun 6, 2022
449303a
nydus-image: bug fix, fix invalid xatttr size
zyfjeff Jun 7, 2022
448cf2b
nydusify: support nydus v6 image build
zyfjeff Jun 6, 2022
e87929f
nydus-image: enable image validate for v6
zyfjeff Jun 7, 2022
8779711
nydus-image: enable rafsv6 smoke test
zyfjeff Jun 7, 2022
90fc1ab
test: disable digest validate for v6
zyfjeff Jun 7, 2022
e57f42d
nydusify: support v6 image build test
zyfjeff Jun 7, 2022
dc1fdcc
nydusify: disable digest validate and use direct mode for v6
zyfjeff Jun 7, 2022
c58ef29
nydusify: rename `image_version` to `fs-version` to be consistent wit…
yawqi Jun 8, 2022
e0c085b
test: fix wrong spelling
zyfjeff Jun 8, 2022
9d991f8
test: safe to stop registry container
zyfjeff Jun 8, 2022
712bd1d
nydus-image: partial implementation inspect subcommand for v6
zyfjeff Jun 8, 2022
2fca2db
Fix code review comments
zyfjeff Jun 8, 2022
8da4bd3
nydusify: change fs-image args usage describe
zyfjeff Jun 8, 2022
e033493
Use native rust way replace if-self
zyfjeff Jun 9, 2022
5bb773d
Handle borrow_mut panic
zyfjeff Jun 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions rafs/src/metadata/direct_v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,6 @@ impl RafsInode for OndiskInodeWrapper {
/// `idx` is the number of child files in line. So we can keep the term `idx`
/// in super crate and keep it consistent with layout v5.
fn get_child_by_index(&self, idx: u32) -> Result<Arc<dyn RafsInode>> {
// Skip DOT and DOTDOT
let idx = idx + 2;
let inode = self.disk_inode();
let child_count = self.get_child_count();

Expand All @@ -821,25 +819,27 @@ impl RafsInode for OndiskInodeWrapper {
.unwrap();
let name_offset = head_entry.e_nameoff;
let entries_count = name_offset as u32 / size_of::<RafsV6Dirent>() as u32;
if cur_idx + entries_count <= idx {
cur_idx += entries_count;
continue;
}

let de = self
.get_entry(i as usize, (idx - cur_idx) as usize)
.map_err(err_invalidate_data)?;

let d_name = self
.entry_name(i as usize, (idx - cur_idx) as usize, entries_count as usize)
.map_err(err_invalidate_data)?;

let nid = de.e_nid;
return Ok(self.mapping.inode_wrapper_with_info(
nid,
self.ino(),
OsString::from(d_name),
)? as Arc<dyn RafsInode>);
for j in 0..entries_count {
let de = self
.get_entry(i as usize, j as usize)
.map_err(err_invalidate_data)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err_invalidate_data is confusing, would you please change it to err_inval_data in a separate patch?

Copy link
Contributor

@zyfjeff zyfjeff Jun 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree it

let name = self
.entry_name(i as usize, j as usize, entries_count as usize)
.map_err(err_invalidate_data)?;
if name == "." || name == ".." {
continue;
}
if cur_idx == idx {
let nid = de.e_nid;
return Ok(self.mapping.inode_wrapper_with_info(
nid,
self.ino(),
OsString::from(name),
)? as Arc<dyn RafsInode>);
}
cur_idx += 1;
}
}

Err(enoent!("invalid child index"))
Expand Down Expand Up @@ -1088,10 +1088,9 @@ impl RafsInode for OndiskInodeWrapper {
let parent_inode = self.mapping.inode_wrapper(self.parent()).unwrap();
let mut curr_name = OsString::from("");

// EROFS packs dot and dotdot, so skip them two.
parent_inode
.walk_children_inodes(
2,
0,
&mut |inode: Option<Arc<dyn RafsInode>>, name: OsString, ino, offset| {
if cur_ino == ino {
curr_name = name;
Expand Down Expand Up @@ -1182,8 +1181,7 @@ impl RafsInode for OndiskInodeWrapper {

let mut child_dirs: Vec<Arc<dyn RafsInode>> = Vec::new();

// EROFS packs dot and dotdot, so skip them two.
self.walk_children_inodes(2, &mut |inode: Option<Arc<dyn RafsInode>>,
self.walk_children_inodes(0, &mut |inode: Option<Arc<dyn RafsInode>>,
name: OsString,
ino,
offset| {
Expand All @@ -1200,8 +1198,11 @@ impl RafsInode for OndiskInodeWrapper {
}
})
.unwrap();

for d in child_dirs {
// EROFS packs dot and dotdot, so skip them two.
if d.name() == "." || d.name() == ".." {
continue;
}
d.collect_descendants_inodes(descendants)?;
}

Expand Down