#include <storage.h>
Collaboration diagram for Storage_system:
Public Methods | |
void | format (unsigned int first_block_to_use=0, unsigned int segment_size=0) |
bool | is_formatted (unsigned int first_block_to_use=0) |
void | init (unsigned int first_block_to_use=0) |
void | write_superblock (unsigned int block_directory=0, unsigned int segment_directory=0, unsigned int curr_empty_segment=0) |
void | checkpoint () |
unsigned int | log_page (void *page, bool update_block_map=true) |
unsigned int | log_map (Address_map &map) |
unsigned int * | load_table (Address_map &map, unsigned int dir_index) |
void | load_page (void *virtual_page) |
void | write_segment () |
void | write_segment_if_full () |
void | set_device (Block_device *device) |
unsigned int | block_to_segment_index (unsigned int segment_block) |
unsigned int | segment_index_to_block (unsigned int segment_index) |
void | enable () |
void | disable () |
Protected Attributes | |
Block_device * | disk |
Segment | curr_segment |
unsigned int | first_block |
unsigned int | blocks_per_segment |
unsigned int | blocks_per_page |
unsigned int | checkpoint_counter |
unsigned int | curr_superblock |
Block_map | block_map |
Segment_map | segment_map |
bool | enabled |
Torsion's particular storage system is of the log-structured variety, which is sort of like a journalling file system, except the entire disk is the journal. An introduction to log-structured storage systems is available in A Log-Structured Persistent Store.
|
Convert a disk block address to its corresponding segment index. (The 0th segment is segment index 0, the 1st segment is segment index 1, etc.).
|
|
Perform a full memory checkpoint to disk.
|
|
Disable the storage system and prevent page loading.
|
|
Enable the storage system and allow page loading.
|
|
Given the first block and the segment size in bytes, create the initial data structures on disk necessary for a storage system. This erases all data on the disk starting from first_block_to_use!
|
|
Initialze this storage system object based on an existing system on disk and perform a recovery if necessary. This is called on boot.
|
|
|
|
Attempt to load the page with the given virtual address. Map the page into memory even if it cannot be found on disk.
|
|
Attempt to load the Address_map table described by the directory entry at the given directory index and return its temporarily mapped virtual address, even if the table cannot be found on disk.
|
|
Add all the dirty tables and the directory of the given address map to the current checkpoint, returning the block number of the directory on disk.
|
|
Add the given in-memory page to the current checkpoint, returning the block number on disk where it was written. If update_block_map is true, record the disk block of the written page in the block map. Each time this function is called, another page is added to the current segment. When there are enough pages to fill up the entire segment, it is flushed to disk and a new one is started. |
|
Convert a segment index to its corresponding disk block address.
|
|
Set the block device upon which this storage system resides.
|
|
Write the current segment to disk and start a new one.
|
|
If the current segment is full, write it to disk and start a new one.
|
|
Write one of the two fixed-position superblocks at the start of the disk, based on checkpoint_counter, curr_superblock, and the given block_directory block address.
|
|
keeps track of live pages on disk.
|
|
page size in blocks.
|
|
segment size in blocks.
|
|
keeps track of last checkpoint.
|
|
current disk segment being used.
|
|
where checkpoint will be recorded.
|
|
disk where this store resides.
|
|
whether storage is active.
|
|
first block of storage system.
|
|
keeps track of segments usage.
|
Torsion Operating System, Copyright (C) 2000-2002 Dan Helfman