pub struct TrackedInodeWriteGuard<'a, 'b, 'c, 'd> {
mem_layout: RwLockWriteGuard<'a, Inode>,
disk_layout: BlockPointsToWriteGuard<'b, 'c, 'd, InodeArray>,
index: usize,
}Expand description
A guard that provides mutable access to the in-memory within a transactional context.
This guard is constructed internally by TrackedInode::write_with
and ensures that any modifications are performed consistently across both
memory and disk. The changes must be explicitly committed using the
associated transaction.
§Panics
If dropped without submitting the change to the transaction, this guard will panic to ensure no silent inconsistency between in-memory and on-disk state.
§Example
tracked_inode.write_with(tx, |mut guard| {
guard.mem_layout.size += 1;
guard.disk_layout[guard.index].size = guard.mem_layout.size;
guard.submit();
Ok(())
})?;Fields§
§mem_layout: RwLockWriteGuard<'a, Inode>Write guard protecting the in-memory inode.
disk_layout: BlockPointsToWriteGuard<'b, 'c, 'd, InodeArray>Write guard protecting the on-disk inode array.
index: usizeIndex to the inode.
Implementations§
Source§impl TrackedInodeWriteGuard<'_, '_, '_, '_>
impl TrackedInodeWriteGuard<'_, '_, '_, '_>
Sourcepub fn submit(self)
pub fn submit(self)
Submits the modified metadata block to the RunningTransaction.
This function marks the block as dirty and ensures it will be written
to disk as part of the journal. After calling submit, the guard is
consumed.
fn do_submit(self)
Methods from Deref<Target = Inode>§
Sourcepub fn into_disk_format(&self) -> Inode
pub fn into_disk_format(&self) -> Inode
Converts the in-memory Inode structure into its on-disk
representation.
This is used when persisting an inode to disk, typically during
checkpointing or journal submission. The returned disk_layout::Inode
struct matches the format expected by the on-disk inode array.
Sourcepub fn get(
&self,
ffs: &FastFileSystemInner,
fba: FileBlockNumber,
) -> Result<Option<LogicalBlockAddress>, KernelError>
pub fn get( &self, ffs: &FastFileSystemInner, fba: FileBlockNumber, ) -> Result<Option<LogicalBlockAddress>, KernelError>
Retrieves the logical block address (LBA) corresponding to a file block.
§Arguments
ffs: Reference to the file system.fba:FileBlockNumber, relative to the beginning of the file.
§Returns
Ok(lba): The logical block address where the specified file block is stored.Err(KernelError): If the block is not allocated or the block number is out of bounds.
Sourcepub fn grow(
&mut self,
ffs: &FastFileSystemInner,
until: FileBlockNumber,
tx: &RunningTransaction<'_>,
) -> Result<(), KernelError>
pub fn grow( &mut self, ffs: &FastFileSystemInner, until: FileBlockNumber, tx: &RunningTransaction<'_>, ) -> Result<(), KernelError>
Grows the inode to include at least the given number of file blocks.
§Arguments
ffs: Reference to the file system.until: The targetFileBlockNumber(inclusive) that the inode should grow to cover.tx: The running transaction used to log allocation changes.
§Returns
Ok(()): If the inode was successfully extended.Err(KernelError): If allocation fails or the inode cannot be grown.
This function ensures that all blocks up to until are allocated,
performing allocation of direct and indirect blocks as needed. The
transaction log is updated to support crash consistency.