@@ -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:: inode:: new_v6_inode;
22
22
use crate :: metadata:: layout:: v6:: {
@@ -41,7 +41,7 @@ impl Node {
41
41
f_bootstrap : & mut dyn RafsIoWrite ,
42
42
orig_meta_addr : u64 ,
43
43
meta_addr : u64 ,
44
- chunk_cache : & mut BTreeMap < DigestWithBlobIndex , Arc < ChunkWrapper > > ,
44
+ chunk_cache : Option < & mut BTreeMap < DigestWithBlobIndex , Arc < ChunkWrapper > > > ,
45
45
) -> Result < ( ) > {
46
46
let xattr_inline_count = self . info . xattrs . count_v6 ( ) ;
47
47
ensure ! (
@@ -69,7 +69,9 @@ impl Node {
69
69
if self . is_dir ( ) {
70
70
self . v6_dump_dir ( ctx, f_bootstrap, meta_addr, meta_offset, & mut inode) ?;
71
71
} else if self . is_reg ( ) {
72
- self . v6_dump_file ( ctx, f_bootstrap, chunk_cache, & mut inode) ?;
72
+ if let Some ( chunk_cache) = chunk_cache {
73
+ self . v6_dump_file ( ctx, f_bootstrap, chunk_cache, & mut inode) ?;
74
+ }
73
75
} else if self . is_symlink ( ) {
74
76
self . v6_dump_symlink ( ctx, f_bootstrap, & mut inode) ?;
75
77
} else {
@@ -685,7 +687,11 @@ impl Bootstrap {
685
687
// Each layer uses the corresponding chunk in the blob of its own layer.
686
688
// If HashChunkDict is used here, it will cause duplication. The chunks are removed,
687
689
// resulting in incomplete chunk info.
688
- let mut chunk_cache = BTreeMap :: new ( ) ;
690
+ let mut chunk_cache = if ctx. features . is_enabled ( Feature :: BlobToc ) {
691
+ None
692
+ } else {
693
+ Some ( BTreeMap :: new ( ) )
694
+ } ;
689
695
690
696
// Dump bootstrap
691
697
timing_tracer ! (
@@ -696,7 +702,7 @@ impl Bootstrap {
696
702
bootstrap_ctx. writer. as_mut( ) ,
697
703
orig_meta_addr,
698
704
meta_addr,
699
- & mut chunk_cache,
705
+ chunk_cache. as_mut ( ) ,
700
706
)
701
707
. context( "failed to dump bootstrap" ) ?;
702
708
}
@@ -725,24 +731,23 @@ impl Bootstrap {
725
731
}
726
732
727
733
// TODO: get rid of the chunk info array.
728
- // Dump chunk info array.
729
- let chunk_table_offset = bootstrap_ctx
730
- . writer
731
- . seek_to_end ( )
732
- . context ( "failed to seek to bootstrap's end for chunk table" ) ?;
733
- let mut chunk_table_size: u64 = 0 ;
734
- for ( _, chunk) in chunk_cache. iter ( ) {
735
- let chunk_size = chunk
736
- . store ( bootstrap_ctx. writer . as_mut ( ) )
737
- . context ( "failed to dump chunk table" ) ?;
738
- chunk_table_size += chunk_size as u64 ;
734
+ if let Some ( chunk_cache) = chunk_cache. as_ref ( ) {
735
+ // Dump chunk info array.
736
+ let chunk_table_offset = bootstrap_ctx
737
+ . writer
738
+ . seek_to_end ( )
739
+ . context ( "failed to seek to bootstrap's end for chunk table" ) ?;
740
+ let mut chunk_table_size: u64 = 0 ;
741
+ for ( _, chunk) in chunk_cache. iter ( ) {
742
+ let chunk_size = chunk
743
+ . store ( bootstrap_ctx. writer . as_mut ( ) )
744
+ . context ( "failed to dump chunk table" ) ?;
745
+ chunk_table_size += chunk_size as u64 ;
746
+ }
747
+ ext_sb. set_chunk_table ( chunk_table_offset, chunk_table_size) ;
748
+ debug ! ( "chunk_table offset {} size {}" , chunk_table_offset, chunk_table_size ) ;
749
+ Self :: v6_align_to_4k ( bootstrap_ctx) ?;
739
750
}
740
- ext_sb. set_chunk_table ( chunk_table_offset, chunk_table_size) ;
741
- debug ! (
742
- "chunk_table offset {} size {}" ,
743
- chunk_table_offset, chunk_table_size
744
- ) ;
745
- Self :: v6_align_to_4k ( bootstrap_ctx) ?;
746
751
747
752
// Prepare device slots.
748
753
let mut pos = bootstrap_ctx
0 commit comments