@@ -16,7 +16,7 @@ use storage::device::BlobFeatures;
16
16
17
17
use super :: chunk_dict:: DigestWithBlobIndex ;
18
18
use super :: node:: Node ;
19
- use crate :: builder:: { Bootstrap , BootstrapContext , BuildContext , ConversionType , Tree } ;
19
+ use crate :: builder:: { Bootstrap , BootstrapContext , BuildContext , ConversionType , Feature , Tree } ;
20
20
use crate :: metadata:: chunk:: ChunkWrapper ;
21
21
use crate :: metadata:: layout:: v6:: {
22
22
align_offset, calculate_nid, new_v6_inode, RafsV6BlobTable , RafsV6Device , RafsV6Dirent ,
@@ -40,7 +40,7 @@ impl Node {
40
40
f_bootstrap : & mut dyn RafsIoWrite ,
41
41
orig_meta_addr : u64 ,
42
42
meta_addr : u64 ,
43
- chunk_cache : & mut BTreeMap < DigestWithBlobIndex , Arc < ChunkWrapper > > ,
43
+ chunk_cache : Option < & mut BTreeMap < DigestWithBlobIndex , Arc < ChunkWrapper > > > ,
44
44
) -> Result < ( ) > {
45
45
let xattr_inline_count = self . info . xattrs . count_v6 ( ) ;
46
46
ensure ! (
@@ -68,7 +68,9 @@ impl Node {
68
68
if self . is_dir ( ) {
69
69
self . v6_dump_dir ( ctx, f_bootstrap, meta_addr, meta_offset, & mut inode) ?;
70
70
} else if self . is_reg ( ) {
71
- self . v6_dump_file ( ctx, f_bootstrap, chunk_cache, & mut inode) ?;
71
+ if let Some ( chunk_cache) = chunk_cache {
72
+ self . v6_dump_file ( ctx, f_bootstrap, chunk_cache, & mut inode) ?;
73
+ }
72
74
} else if self . is_symlink ( ) {
73
75
self . v6_dump_symlink ( ctx, f_bootstrap, & mut inode) ?;
74
76
} else {
@@ -709,7 +711,11 @@ impl Bootstrap {
709
711
// Each layer uses the corresponding chunk in the blob of its own layer.
710
712
// If HashChunkDict is used here, it will cause duplication. The chunks are removed,
711
713
// resulting in incomplete chunk info.
712
- let mut chunk_cache = BTreeMap :: new ( ) ;
714
+ let mut chunk_cache = if ctx. features . is_enabled ( Feature :: BlobToc ) {
715
+ None
716
+ } else {
717
+ Some ( BTreeMap :: new ( ) )
718
+ } ;
713
719
714
720
// Dump bootstrap
715
721
timing_tracer ! (
@@ -720,7 +726,7 @@ impl Bootstrap {
720
726
bootstrap_ctx. writer. as_mut( ) ,
721
727
orig_meta_addr,
722
728
meta_addr,
723
- & mut chunk_cache,
729
+ chunk_cache. as_mut ( ) ,
724
730
)
725
731
. context( "failed to dump bootstrap" ) ?;
726
732
}
@@ -751,24 +757,26 @@ impl Bootstrap {
751
757
}
752
758
753
759
// TODO: get rid of the chunk info array.
754
- // Dump chunk info array.
755
- let chunk_table_offset = bootstrap_ctx
756
- . writer
757
- . seek_to_end ( )
758
- . context ( "failed to seek to bootstrap's end for chunk table" ) ?;
759
- let mut chunk_table_size: u64 = 0 ;
760
- for ( _, chunk) in chunk_cache. iter ( ) {
761
- let chunk_size = chunk
762
- . store ( bootstrap_ctx. writer . as_mut ( ) )
763
- . context ( "failed to dump chunk table" ) ?;
764
- chunk_table_size += chunk_size as u64 ;
760
+ if let Some ( chunk_cache) = chunk_cache. as_ref ( ) {
761
+ // Dump chunk info array.
762
+ let chunk_table_offset = bootstrap_ctx
763
+ . writer
764
+ . seek_to_end ( )
765
+ . context ( "failed to seek to bootstrap's end for chunk table" ) ?;
766
+ let mut chunk_table_size: u64 = 0 ;
767
+ for ( _, chunk) in chunk_cache. iter ( ) {
768
+ let chunk_size = chunk
769
+ . store ( bootstrap_ctx. writer . as_mut ( ) )
770
+ . context ( "failed to dump chunk table" ) ?;
771
+ chunk_table_size += chunk_size as u64 ;
772
+ }
773
+ ext_sb. set_chunk_table ( chunk_table_offset, chunk_table_size) ;
774
+ debug ! (
775
+ "chunk_table offset {} size {}" ,
776
+ chunk_table_offset, chunk_table_size
777
+ ) ;
778
+ Self :: v6_align_to_4k ( bootstrap_ctx) ?;
765
779
}
766
- ext_sb. set_chunk_table ( chunk_table_offset, chunk_table_size) ;
767
- debug ! (
768
- "chunk_table offset {} size {}" ,
769
- chunk_table_offset, chunk_table_size
770
- ) ;
771
- Self :: v6_align_to_4k ( bootstrap_ctx) ?;
772
780
773
781
// Prepare device slots.
774
782
let mut pos = bootstrap_ctx
0 commit comments