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

        let blocks = metadata.header.index_start
            + Aligned::get_blocks(
                (metadata.header.max_entries * metadata.header.entry_size)
                    as u64,
                block_size,
            );
        let mut buf = DmaBuf::new(blocks * block_size, bdev.alignment())
            .context(WriteAlloc {
                name: String::from("index"),
            })?;
        let mut writer = Cursor::new(buf.as_mut_slice());

        // Header
        serialize_into(&mut writer, &metadata.header)
            .context(SerializeError {})?;

        // Index
        writer
            .seek(SeekFrom::Start(metadata.header.index_start * block_size))
            .unwrap();
        for entry in &metadata.index {
            serialize_into(&mut writer, entry).context(SerializeError {})?;
        }

        hndl.write_at(metadata.header.self_lba * block_size, &buf)
            .await
            .context(WriteError {
                name: String::from("index"),
            })?;

        Ok(())
    }
/// Write the Metadata header + index to disk
Write the Metadata header + index to disk
Write the Metadata header + index to disk
async fn write_index(
        &self,
        metadata: &NexusMetaData,
    ) -> Result<(), MetaDataError> {
        let (bdev, hndl) = self.get_dev().context(NexusChildError {})?;
        let block_size = bdev.block_len() as u64;
        let blocks = metadata.header.index_start
            + Aligned::get_blocks(
                (metadata.header.max_entries * metadata.header.entry_size)
                    as u64,
                block_size,
            );
        let mut buf = DmaBuf::new(blocks * block_size, bdev.alignment())
            .context(WriteAlloc {
                name: String::from("index"),
            })?;
        let mut writer = Cursor::new(buf.as_mut_slice());
        // Header
        serialize_into(&mut writer, &metadata.header)
            .context(SerializeError {})?;
        // Index
        writer
            .seek(SeekFrom::Start(metadata.header.index_start * block_size))
            .unwrap();
        for entry in &metadata.index {
            serialize_into(&mut writer, entry).context(SerializeError {})?;
        }
        hndl.write_at(metadata.header.self_lba * block_size, &buf)
            .await
            .context(WriteError {
                name: String::from("index"),
            })?;
        Ok(())
    }
async fn write_index ( & self , metadata : & NexusMetaData , ) -> Result < ( ) , MetaDataError > { let ( bdev , hndl ) = self . get_dev ( ) . context ( NexusChildError { } ) ? ; let block_size = bdev . block_len ( ) as u64 ; let blocks = metadata . header . index_start + Aligned :: get_blocks ( ( metadata . header . max_entries * metadata . header . entry_size ) as u64 , block_size , ) ; let mut buf = DmaBuf :: new ( blocks * block_size , bdev . alignment ( ) ) . context ( WriteAlloc { name : String :: from ( " " ) , } ) ? ; let mut writer = Cursor :: new ( buf . as_mut_slice ( ) ) ; // Header serialize_into ( & mut writer , & metadata . header ) . context ( SerializeError { } ) ? ; // Index writer . seek ( SeekFrom :: Start ( metadata . header . index_start * block_size ) ) . unwrap ( ) ; for entry in & metadata . index { serialize_into ( & mut writer , entry ) . context ( SerializeError { } ) ? ; } hndl . write_at ( metadata . header . self_lba * block_size , & buf ) . await . context ( WriteError { name : String :: from ( " " ) , } ) ? ; Ok ( ( ) ) }
Write the Metadata header + index to disk
Write the Metadata header + index to disk
&self
metadata
&NexusMetaData