async fn compact(
        &mut self,
        metadata: &mut NexusMetaData,
    ) -> Result<(), MetaDataError> {
        let (bdev, hndl) = self.get_dev().context(NexusChildError {})?;
        let block_size = bdev.block_len() as u64;
        let alignment = bdev.alignment();

        let self_lba = metadata.header.self_lba;
        let mut start = metadata.header.data_start;

        for entry in &mut metadata.index {
            if entry.data_start > start {
                let blocks = entry.data_end - entry.data_start;
                let mut buf = DmaBuf::new((blocks + 1) * block_size, alignment)
                    .context(ReadAlloc {
                        name: String::from("object"),
                    })?;
                hndl.read_at(
                    (self_lba + entry.data_start) * block_size,
                    &mut buf,
                )
                .await
                .context(ReadError {
                    name: String::from("object"),
                })?;
                hndl.write_at((self_lba + start) * block_size, &buf)
                    .await
                    .context(WriteError {
                        name: String::from("object"),
                    })?;
                entry.data_start = start;
                entry.data_end = start + blocks;
            }
            start = entry.data_end + 1;
        }

        Ok(())
    }
/// Defragment the data defined by the index, and update the index in situ.
Defragment the data defined by the index, and update the index in situ.
Defragment the data defined by the index and update the index in situ .
async fn compact(
        &mut self,
        metadata: &mut NexusMetaData,
    ) -> Result<(), MetaDataError> {
        let (bdev, hndl) = self.get_dev().context(NexusChildError {})?;
        let block_size = bdev.block_len() as u64;
        let alignment = bdev.alignment();
        let self_lba = metadata.header.self_lba;
        let mut start = metadata.header.data_start;
        for entry in &mut metadata.index {
            if entry.data_start > start {
                let blocks = entry.data_end - entry.data_start;
                let mut buf = DmaBuf::new((blocks + 1) * block_size, alignment)
                    .context(ReadAlloc {
                        name: String::from("object"),
                    })?;
                hndl.read_at(
                    (self_lba + entry.data_start) * block_size,
                    &mut buf,
                )
                .await
                .context(ReadError {
                    name: String::from("object"),
                })?;
                hndl.write_at((self_lba + start) * block_size, &buf)
                    .await
                    .context(WriteError {
                        name: String::from("object"),
                    })?;
                entry.data_start = start;
                entry.data_end = start + blocks;
            }
            start = entry.data_end + 1;
        }
        Ok(())
    }
async fn compact ( & mut self , metadata : & mut NexusMetaData , ) -> Result < ( ) , MetaDataError > { let ( bdev , hndl ) = self . get_dev ( ) . context ( NexusChildError { } ) ? ; let block_size = bdev . block_len ( ) as u64 ; let alignment = bdev . alignment ( ) ; let self_lba = metadata . header . self_lba ; let mut start = metadata . header . data_start ; for entry in & mut metadata . index { if entry . data_start > start { let blocks = entry . data_end - entry . data_start ; let mut buf = DmaBuf :: new ( ( blocks + 1 ) * block_size , alignment ) . context ( ReadAlloc { name : String :: from ( " " ) , } ) ? ; hndl . read_at ( ( self_lba + entry . data_start ) * block_size , & mut buf , ) . await . context ( ReadError { name : String :: from ( " " ) , } ) ? ; hndl . write_at ( ( self_lba + start ) * block_size , & buf ) . await . context ( WriteError { name : String :: from ( " " ) , } ) ? ; entry . data_start = start ; entry . data_end = start + blocks ; } start = entry . data_end + 1 ; } Ok ( ( ) ) }
Defragment the data defined by the index, and update the index in situ.
Defragment the data defined by the index and update the index in situ .
&mut self
metadata
&mut NexusMetaData