/// Load all inodes into memory.
///
/// Rafs v5 layout is based on BFS, which means parents always are in front of children.
Load all inodes into memory.
Rafs v5 layout is based on BFS, which means parents always are in front of children.
Load all inodes into memory . Rafs v5 layout is based on BFS which means parents always are in front of children .
fn load_all_inodes(&mut self, r: &mut RafsIoReader) -> Result<()> {
        let mut dir_ino_set = Vec::with_capacity(self.s_meta.inode_table_entries as usize);
        for _idx in 0..self.s_meta.inode_table_entries {
            let mut inode = CachedInodeV5::new(self.s_blob.clone(), self.s_meta.clone());
            match inode.load(&self.s_meta, r) {
                Ok(_) => {
                    trace!(
                        "got inode ino {} parent {} size {} child_idx {} child_cnt {}",
                        inode.ino(),
                        inode.parent(),
                        inode.size(),
                        inode.i_child_idx,
                        inode.i_child_cnt,
                    );
                }
                Err(ref e) if e.kind() == ErrorKind::UnexpectedEof => break,
                Err(e) => {
                    error!("error when loading CachedInode {:?}", e);
                    return Err(e);
                }
            }
            let child_inode = self.hash_inode(Arc::new(inode))?;
            if child_inode.is_dir() {
                // Delay associating dir inode to its parent because that will take
                // a cloned inode object, which preventing us from using `Arc::get_mut`.
                // Without `Arc::get_mut` during Cached meta setup(loading all inodes),
                // we have to lock inode everywhere for mutability. It really hurts.
                dir_ino_set.push(child_inode.i_ino);
            } else {
                self.add_into_parent(child_inode);
            }
        }
        // Add directories to its parent in reverse order.
        for ino in dir_ino_set.iter().rev() {
            self.add_into_parent(self.get_node(*ino)?);
        }
        debug!("all {} inodes loaded", self.s_inodes.len());
        Ok(())
    }
fn load_all_inodes ( & mut self , r : & mut RafsIoReader ) -> Result < ( ) > { let mut dir_ino_set = Vec :: with_capacity ( self . s_meta . inode_table_entries as usize ) ; for _idx in 0 .. self . s_meta . inode_table_entries { let mut inode = CachedInodeV5 :: new ( self . s_blob . clone ( ) , self . s_meta . clone ( ) ) ; match inode . load ( & self . s_meta , r ) { Ok ( _ ) => { trace ! ( " " inode ino ( ) inode parent ( ) inode size ( ) inode i_child_idx inode i_child_cnt ) ; } Err ( ref e ) if e . kind ( ) == ErrorKind :: UnexpectedEof => break , Err ( e ) => { error ! ( " " e ) ; return Err ( e ) ; } } let child_inode = self . hash_inode ( Arc :: new ( inode ) ) ? ; if child_inode . is_dir ( ) { // Delay associating dir inode to its parent because that will take // a cloned inode object, which preventing us from using `Arc::get_mut`. // Without `Arc::get_mut` during Cached meta setup(loading all inodes), // we have to lock inode everywhere for mutability. It really hurts. dir_ino_set . push ( child_inode . i_ino ) ; } else { self . add_into_parent ( child_inode ) ; } } // Add directories to its parent in reverse order. for ino in dir_ino_set . iter ( ) . rev ( ) { self . add_into_parent ( self . get_node ( * ino ) ? ) ; } debug ! ( " " self s_inodes len ( ) ) ; Ok ( ( ) ) }
Load all inodes into memory.
Load all inodes into memory .
&mut self
r
&mut RafsIoReader