Skip to content

nydus-image: fixed a bug caused by empty blob and prefetched combined scenes #495

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

Merged
merged 4 commits into from
Jun 16, 2022

Conversation

zyfjeff
Copy link
Contributor

@zyfjeff zyfjeff commented Jun 14, 2022

When building a layer independently, if the layer does not produce any blobs, but the prefetch is set,
the position of the prefetch table and the position of the inode table will overlap,
resulting in the prefetch table overwriting part of the inode table.

Signed-off-by: zyfjeff [email protected]

@zyfjeff zyfjeff force-pushed the fix-prefetch-bug branch 5 times, most recently from 98efc1c to 572bbdf Compare June 15, 2022 01:41
… scenes

When building a layer independently, if the layer does not produce any blobs, but the prefetch is set,
the position of the prefetch table and the position of the inode table will overlap,
resulting in the prefetch table overwriting part of the inode table.

blob table|prefetch table|inode table

blob table + prefetch table is a whole, 4K alignment, if blob table size is equal to 0, but prefetchtable is not equal to 0,
will cause the prefetch table to exist, but will not be 4k aligned, and overlap with the inode table.

Related code

        let orig_meta_addr = bootstrap_ctx.nodes[0].offset - EROFS_BLOCK_SIZE;
        let meta_addr = if blob_table_size > 0 {
            align_offset(
                blob_table_offset + blob_table_size + prefetch_table_size as u64,
                EROFS_BLOCK_SIZE as u64,
            )
        } else {
            orig_meta_addr
        };
        let root_nid = calculate_nid(
            bootstrap_ctx.nodes[0].offset - orig_meta_addr + meta_addr,
            meta_addr,
        );
Signed-off-by: zyfjeff <[email protected]>
@zyfjeff zyfjeff force-pushed the fix-prefetch-bug branch from 572bbdf to 56d21d2 Compare June 15, 2022 01:57
@zyfjeff zyfjeff changed the title Wip: fixed a bug caused by empty blob and prefetched combined scenes nydus-image: fixed a bug caused by empty blob and prefetched combined scenes Jun 15, 2022
self.dump_meta_data(blob_ctx)?;
// Dump is only required if there is chunk in the blob
if has_chunk {
self.dump_meta_data(blob_ctx)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to check blob_ctx.compressed_blob_size or blob_ctx.chunk_count in dump_meta_data, so that we can reuse this logic for stargz build in future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

tests/builder.rs Outdated
).unwrap();
}

pub fn build_empty_file_with_prefetch(&mut self) {
Copy link
Collaborator

@imeoer imeoer Jun 15, 2022

Choose a reason for hiding this comment

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

Why not follow build_lower and build_upper (create new one named builder_empty, and enable prefetch for all test cases)? so that we can reuse the test func in tests/smoke.rs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bugs only occur when prefetched and empty files are combined, so there are no build_lower and build_upper used here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This case and other tests have now been combined.

@zyfjeff zyfjeff force-pushed the fix-prefetch-bug branch 2 times, most recently from ee741ee to dcfd0dd Compare June 15, 2022 09:23
Signed-off-by: zyfjeff <[email protected]>
@zyfjeff zyfjeff force-pushed the fix-prefetch-bug branch 3 times, most recently from a37f49b to 8145b40 Compare June 16, 2022 03:50
@zyfjeff zyfjeff force-pushed the fix-prefetch-bug branch from 8145b40 to f5161a1 Compare June 16, 2022 03:52
self.dump_meta_data(blob_ctx)?;
// Dump is only required if there is chunk in the blob
if blob_ctx.compressed_blob_size > 0 {
self.dump_meta_data(blob_ctx)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move the if blob_ctx.compressed_blob_size > 0 check into dump_meta_data should be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@zyfjeff zyfjeff force-pushed the fix-prefetch-bug branch from dd701a6 to ce79edd Compare June 16, 2022 07:21
@imeoer imeoer merged commit ac4c7f1 into dragonflyoss:master Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants