#include <storage.h>
Collaboration diagram for Storage_system:

Public Member Functions | |
| void | format (unsigned first_block_to_use=0, Size segment_size=0) |
| bool | is_formatted (unsigned first_block_to_use=0) |
| void | init (unsigned first_block_to_use=0) |
| void | write_superblock (unsigned block_directory=0, unsigned segment_directory=0, unsigned curr_empty_segment=0) |
| void | checkpoint () |
| unsigned | log_page (void *page, bool update_block_map=true, void *actual_page_addr=NULL) |
| void | free_page (void *page) |
| unsigned | log_map (Address_map &map) |
| unsigned * | load_table (Address_map &map, unsigned dir_index, void *virtual_table) |
| void | load_page (void *virtual_page) |
| void | write_segment () |
| void | write_segment_if_full () |
| bool | clean (unsigned segments_to_clean) |
| void | get_live_pages (Segment &segment, Array< void * > &live_pages) |
| void | set_device (Block_device *device) |
| unsigned | block_to_segment_index (unsigned segment_block) |
| unsigned | segment_index_to_block (unsigned segment_index) |
| void | enable () |
| void | disable () |
| bool | is_checkpointing_dirty_pages () |
| void | print () |
Protected Attributes | |
| Block_device * | disk |
| Segment | curr_segment |
| unsigned | first_block |
| Size | blocks_per_segment |
| Size | blocks_per_page |
| unsigned | checkpoint_counter |
| unsigned | curr_superblock |
| Block_map | block_map |
| Segment_map | segment_map |
| Array< unsigned > | cleaned_segments |
| bool | checkpointing_dirty_pages |
| bool | enabled |
Static Protected Attributes | |
| const unsigned | block_map_id_mask = 1 << 11 |
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. If necessary, the caller should clean the disk first to free up segments and make room for the pages that will be written during the checkpoint. |
|
|
Compact live pages and recover space used by freed/obsolete pages. Do this by loading live pages from partially used segments into memory. These live pages will be written to disk on the next checkpoint, leaving behind freed/obsolete pages so that their segments can then be reused for logging. segments_to_clean is the number of segments to clean. Returns true if the given number of segments were actually cleaned, and false otherwise. |
|
|
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! |
|
|
Remove the given page from the block map.
|
|
||||||||||||
|
Determine the live pages in the segment and append them to the given array.
|
|
|
Initialze this storage system object based on an existing system on disk and perform a recovery if necessary. This is called on boot. |
|
|
Return true if the checkpointer is running and is currently logging dirty pages to disk.
|
|
|
Determine whether a valid Torsion storage system begins on disk at the given block number.
|
|
|
Attempt to load the page with the given virtual address.
|
|
||||||||||||||||
|
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. If given, actual_page_addr is the address of the page to store as the page's permanent virtual address. This is useful if, for instance, the page argument is just a temporary address. |
|
|
Print basic information about this Storage_system.
|
|
|
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 function arguments.
|
|
|
keeps track of live pages on disk
|
|
|
|
|
|
page size in blocks
|
|
|
segment size in blocks
|
|
|
keeps track of last checkpoint
|
|
|
whether a checkpoint is underway
|
|
|
recently cleaned segment indices
|
|
|
current disk segment being used
|
|
|
where checkpoint will be recorded
|
|
|
disk where this store resides
|
|
|
unique block map identifier
|
|
|
first block of storage system
|
|
|
keeps track of segments usage
|
Torsion Operating System, Copyright (C) 2000-2004 Dan Helfman