fn update_cluster_addr(
        &mut self,
        l1_index: usize,
        l2_index: usize,
        cluster_addr: u64,
        set_refcounts: &mut Vec<(u64, u16)>,
    ) -> io::Result<()> {
        if !self.l2_cache.get(l1_index).unwrap().dirty() {
            // Free the previously used cluster if one exists. Modified tables are always
            // witten to new clusters so the L1 table can be committed to disk after they
            // are and L1 never points at an invalid table.
            // The index must be valid from when it was inserted.
            let addr = self.l1_table[l1_index];
            if addr != 0 {
                self.unref_clusters.push(addr);
                set_refcounts.push((addr, 0));
            }

            // Allocate a new cluster to store the L2 table and update the L1 table to point
            // to the new table. The cluster will be written when the cache is flushed, no
            // need to copy the data now.
            let new_addr: u64 = self.get_new_cluster()?;
            // The cluster refcount starts at one indicating it is used but doesn't need
            // COW.
            set_refcounts.push((new_addr, 1));
            self.l1_table[l1_index] = new_addr;
        }
        // 'unwrap' is OK because it was just added.
        self.l2_cache.get_mut(l1_index).unwrap()[l2_index] = cluster_addr;
        Ok(())
    }
// Updates the l1 and l2 tables to point to the new `cluster_addr`.
Updates the l1 and l2 tables to point to the new `cluster_addr`.
Updates the l1 and l2 tables to point to the new ` cluster_addr ` .
fn update_cluster_addr(
        &mut self,
        l1_index: usize,
        l2_index: usize,
        cluster_addr: u64,
        set_refcounts: &mut Vec<(u64, u16)>,
    ) -> io::Result<()> {
        if !self.l2_cache.get(l1_index).unwrap().dirty() {
            // Free the previously used cluster if one exists. Modified tables are always
            // witten to new clusters so the L1 table can be committed to disk after they
            // are and L1 never points at an invalid table.
            // The index must be valid from when it was inserted.
            let addr = self.l1_table[l1_index];
            if addr != 0 {
                self.unref_clusters.push(addr);
                set_refcounts.push((addr, 0));
            }
            // Allocate a new cluster to store the L2 table and update the L1 table to point
            // to the new table. The cluster will be written when the cache is flushed, no
            // need to copy the data now.
            let new_addr: u64 = self.get_new_cluster()?;
            // The cluster refcount starts at one indicating it is used but doesn't need
            // COW.
            set_refcounts.push((new_addr, 1));
            self.l1_table[l1_index] = new_addr;
        }
        // 'unwrap' is OK because it was just added.
        self.l2_cache.get_mut(l1_index).unwrap()[l2_index] = cluster_addr;
        Ok(())
    }
fn update_cluster_addr ( & mut self , l1_index : usize , l2_index : usize , cluster_addr : u64 , set_refcounts : & mut Vec < ( u64 , u16 ) > , ) -> io :: Result < ( ) > { if ! self . l2_cache . get ( l1_index ) . unwrap ( ) . dirty ( ) { // Free the previously used cluster if one exists. Modified tables are always // witten to new clusters so the L1 table can be committed to disk after they // are and L1 never points at an invalid table. // The index must be valid from when it was inserted. let addr = self . l1_table [ l1_index ] ; if addr != 0 { self . unref_clusters . push ( addr ) ; set_refcounts . push ( ( addr , 0 ) ) ; } // Allocate a new cluster to store the L2 table and update the L1 table to point // to the new table. The cluster will be written when the cache is flushed, no // need to copy the data now. let new_addr : u64 = self . get_new_cluster ( ) ? ; // The cluster refcount starts at one indicating it is used but doesn't need // COW. set_refcounts . push ( ( new_addr , 1 ) ) ; self . l1_table [ l1_index ] = new_addr ; } // 'unwrap' is OK because it was just added. self . l2_cache . get_mut ( l1_index ) . unwrap ( ) [ l2_index ] = cluster_addr ; Ok ( ( ) ) }
Updates the l1 and l2 tables to point to the new `cluster_addr`.
Updates the l1 and l2 tables to point to the new ` cluster_addr ` .
&mut self
l1_index
usize
l2_index
usize
cluster_addr
u64
set_refcounts
&mut Vec<(u64, u16)>
&mut self
l1_index
usize
l2_index
usize
cluster_addr
u64
set_refcounts
&mut Vec<(u64, u16)>