-
Notifications
You must be signed in to change notification settings - Fork 230
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
Conversation
98efc1c
to
572bbdf
Compare
… 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]>
572bbdf
to
56d21d2
Compare
src/bin/nydus-image/core/blob.rs
Outdated
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)?; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
ee741ee
to
dcfd0dd
Compare
Signed-off-by: zyfjeff <[email protected]>
a37f49b
to
8145b40
Compare
Signed-off-by: zyfjeff <[email protected]>
8145b40
to
f5161a1
Compare
src/bin/nydus-image/core/blob.rs
Outdated
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)?; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Signed-off-by: zyfjeff <[email protected]>
dd701a6
to
ce79edd
Compare
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]