Skip to content

Commit

Permalink
rafs: fix a assertion failure in prefetch list generation
Browse files Browse the repository at this point in the history
Fix a assertion failure in prefetch list generation.

Fixes: dragonflyoss#1154

Signed-off-by: Jiang Liu <[email protected]>
  • Loading branch information
jiangliu committed Mar 21, 2023
1 parent bca47e3 commit 49fc71e
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions rafs/src/builder/core/v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,19 +708,21 @@ impl Bootstrap {
Self::v6_align_to_4k(bootstrap_ctx)?;

// `Node` offset might be updated during above inodes dumping. So `get_prefetch_table` after it.
let prefetch_table = ctx
.prefetch
.get_v6_prefetch_table(&bootstrap_ctx.nodes, meta_addr);
if let Some(mut pt) = prefetch_table {
assert!(pt.len() * size_of::<u32>() <= prefetch_table_size as usize);
// Device slots are very close to extended super block.
ext_sb.set_prefetch_table_offset(prefetch_table_offset);
ext_sb.set_prefetch_table_size(prefetch_table_size);
bootstrap_ctx
.writer
.seek_offset(prefetch_table_offset as u64)
.context("failed seek prefetch table offset")?;
pt.store(bootstrap_ctx.writer.as_mut()).unwrap();
if prefetch_table_size > 0 {
let prefetch_table = ctx
.prefetch
.get_v6_prefetch_table(&bootstrap_ctx.nodes, meta_addr);
if let Some(mut pt) = prefetch_table {
assert!(pt.len() * size_of::<u32>() <= prefetch_table_size as usize);
// Device slots are very close to extended super block.
ext_sb.set_prefetch_table_offset(prefetch_table_offset);
ext_sb.set_prefetch_table_size(prefetch_table_size);
bootstrap_ctx
.writer
.seek_offset(prefetch_table_offset as u64)
.context("failed seek prefetch table offset")?;
pt.store(bootstrap_ctx.writer.as_mut()).unwrap();
}
}

// TODO: get rid of the chunk info array.
Expand Down

0 comments on commit 49fc71e

Please sign in to comment.