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

Fixes two bugs for rafs v5 #1275

Merged
merged 2 commits into from
May 16, 2023
Merged

Fixes two bugs for rafs v5 #1275

merged 2 commits into from
May 16, 2023

Conversation

jiangliu
Copy link
Collaborator

Fixes two bugs for rafs v5:

  • record correct inode number for v5
  • avoid a possible panic for v5

@jiangliu jiangliu requested a review from a team as a code owner May 13, 2023 17:01
@jiangliu jiangliu requested review from liubin, liubogithub and luodw and removed request for a team May 13, 2023 17:01
@anolis-bot
Copy link
Collaborator

@jiangliu , a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/72439

@codecov
Copy link

codecov bot commented May 13, 2023

Codecov Report

Merging #1275 (47afaac) into master (db0cc41) will increase coverage by 0.00%.
The diff coverage is 72.72%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1275   +/-   ##
=======================================
  Coverage   45.06%   45.07%           
=======================================
  Files         126      126           
  Lines       37395    37403    +8     
  Branches    37395    37403    +8     
=======================================
+ Hits        16852    16858    +6     
- Misses      19655    19656    +1     
- Partials      888      889    +1     
Impacted Files Coverage Δ
rafs/src/metadata/md_v5.rs 15.38% <0.00%> (ø)
rafs/src/builder/core/bootstrap.rs 53.45% <100.00%> (+1.78%) ⬆️

... and 3 files with indirect coverage changes

@anolis-bot
Copy link
Collaborator

@jiangliu , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd✅ SUCCESS
compile ctr remote✅ SUCCESS
compile nydus snapshotter✅ SUCCESS
run container with rafs✅ SUCCESS
run container with zran✅ SUCCESS
run container with rafs and compile linux✅ SUCCESS

Congratulations, your test job passed!

@@ -187,7 +187,7 @@ impl Bootstrap {

// Set super block
let mut super_block = RafsV5SuperBlock::new();
let inodes_count = bootstrap_ctx.inode_map.len() as u64;
let inodes_count = bootstrap_ctx.inode_map.len() as u64 + 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have this plus one before?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, I found the inodes count is incorrect for v5.

Copy link
Member

Choose a reason for hiding this comment

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

Could you explain more about what this is trying to fix? Why must the inode count be one more than the actual recorded inode number on the map? Or is it because we forgot to insert the root inode in the inode_map?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the root inode is missing here:

root@903f8fcca5c8:/nydus# target/debug/nydus-image inspect images/0de6bc4212c22aa2bcc8026697cbb93db330421c7a3a09f3ae2cfa9b90c4332c 
[2023-05-15 09:35:34.626189 +00:00] INFO RAFS v5 super block features: HASH_BLAKE3 | EXPLICIT_UID_GID | COMPRESSION_ZSTD
Inspecting RAFS :> stats

    Version:                5
    Inodes Count:           1
    Chunk Size:             1024KB
    Root Inode:             1
    Flags:                  HASH_BLAKE3 | EXPLICIT_UID_GID | COMPRESSION_ZSTD
    Blob table offset:      0x2008
    Blob table size:        0x0
    Prefetch table offset:  0x2008
    Prefetch table entries: 0x0
    Chunk table offset:     0x0
    Chunk table size:       0x0
    
Inspecting RAFS :> ls
-    2        "text.txt"
Inspecting RAFS :> 

Copy link
Member

Choose a reason for hiding this comment

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

Earlier on, we had

        tree.node.index = RAFS_ROOT_INODE;
        tree.node.inode.set_ino(RAFS_ROOT_INODE);
        // Filesystem walking skips root inode within subsequent while loop, however, we allow
        // user to pass the source root as prefetch hint. Check it here.
        ctx.prefetch.insert_if_need(&tree.node);

        bootstrap_ctx.inode_map.insert(
            (tree.node.layer_idx, tree.node.src_ino, tree.node.src_dev),
            vec![tree.node.index],
        );

Should we add it back instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The inode_map is used to detect hardlinks for regular files, so it doesn't make sense to add directories inode (including /) into the inode_map. How about adding a comments for the `+`` instead?

Copy link
Member

Choose a reason for hiding this comment

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

But we have all the other directory inodes (except for the root inode) in the inode_map, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fair enough:)

@@ -187,7 +187,7 @@ impl Bootstrap {

// Set super block
let mut super_block = RafsV5SuperBlock::new();
let inodes_count = bootstrap_ctx.inode_map.len() as u64;
let inodes_count = bootstrap_ctx.inode_map.len() as u64 + 1;
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain more about what this is trying to fix? Why must the inode count be one more than the actual recorded inode number on the map? Or is it because we forgot to insert the root inode in the inode_map?

let next_size = if next_size < window_size {
let next_size = if next_size == 0 {
continue;
} else if next_size < window_size {
Copy link
Member

Choose a reason for hiding this comment

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

Which debug_assert is triggered by this? Could you paste the error message?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Refined the commit message.

Copy link
Member

Choose a reason for hiding this comment

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

Cannot find it. Did you forget to push the new code? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

@anolis-bot
Copy link
Collaborator

@jiangliu , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/72770

In function RafsSuper::amplify_io(), is the next inode `ni` is
zero-sized, the debug assertion in function calculate_bio_chunk_index()
(rafs/src/metadata/layout/v5.rs) will get triggered. So zero-sized
file should be skipped by amplify_io().

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
@anolis-bot
Copy link
Collaborator

@jiangliu , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/72771

@anolis-bot
Copy link
Collaborator

@jiangliu , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd✅ SUCCESS
compile ctr remote✅ SUCCESS
compile nydus snapshotter✅ SUCCESS
run container with rafs✅ SUCCESS
run container with zran✅ SUCCESS
run container with rafs and compile linux✅ SUCCESS

Congratulations, your test job passed!

@anolis-bot
Copy link
Collaborator

@jiangliu , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd✅ SUCCESS
compile ctr remote✅ SUCCESS
compile nydus snapshotter✅ SUCCESS
run container with rafs✅ SUCCESS
run container with zran✅ SUCCESS
run container with rafs and compile linux❌ FAIL

Sorry, your test job failed. Please get the details in the link.

Add root inode into inode map when building RAFS filesystem,
so RAFS v5 gets correct inode number counts.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
@anolis-bot
Copy link
Collaborator

@jiangliu , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/72973

@anolis-bot
Copy link
Collaborator

@jiangliu , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd✅ SUCCESS
compile ctr remote✅ SUCCESS
compile nydus snapshotter✅ SUCCESS
run container with rafs✅ SUCCESS
run container with zran✅ SUCCESS
run container with rafs and compile linux✅ SUCCESS

Congratulations, your test job passed!

Copy link
Member

@bergwolf bergwolf left a comment

Choose a reason for hiding this comment

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

lgtm! Thanks!

@bergwolf bergwolf merged commit 293b032 into dragonflyoss:master May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants