Skip to content

Commit

Permalink
nydus-image: fixed getting the wrong chunk content due to using the w…
Browse files Browse the repository at this point in the history
…rong blob index

The blob index on the disk where erofs exists starts at 1, but the blob index in BlobInfo starts at 0,
and the blob index on the disk is mistakenly used here instead of blobInfo's index

Signed-off-by: zyfjeff <zyfjeff@linux.alibaba.com>
  • Loading branch information
zyfjeff committed Jul 7, 2022
1 parent b923b5d commit 29bd1be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rafs/src/metadata/direct_v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ impl RafsInode for OndiskInodeWrapper {
content_len = std::cmp::min(chunk_size, left);
let desc = self.make_chunk_io(c, 0, content_len, user_io);

if c.blob_index() as u32 != descs.bi_vec[0].blob.blob_index() {
if desc.blob.blob_index() as u32 != descs.bi_vec[0].blob.blob_index() {
vec.push(descs);
descs = BlobIoVec::new();
}
Expand Down
3 changes: 3 additions & 0 deletions rafs/src/metadata/layout/v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,9 @@ impl RafsV6InodeChunkAddr {
}
}

/// Note: for erofs, bump id by 1 since device id 0 is bootstrap.
/// The index in BlobInfo grows from 0, so when using this method to index the corresponding blob,
/// the index always needs to be incremented by 1
/// Get the blob index of the chunk.
pub fn blob_index(&self) -> u8 {
(u16::from_le(self.c_blob_addr_hi) & 0x00ff) as u8
Expand Down

0 comments on commit 29bd1be

Please sign in to comment.