Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Storage_system Class Reference

A storage system is simply a file system that stores pages of memory instead of files. More...

#include <storage.h>

Collaboration diagram for Storage_system:

Collaboration graph
[legend]
List of all members.

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_devicedisk
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

Detailed Description

A storage system is simply a file system that stores pages of memory instead of files.

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.


Member Function Documentation

unsigned int Storage_system::block_to_segment_index unsigned int    segment_block [inline]
 

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.).

void Storage_system::checkpoint  
 

Perform a full memory checkpoint to disk.

void Storage_system::disable   [inline]
 

Disable the storage system and prevent page loading.

void Storage_system::enable   [inline]
 

Enable the storage system and allow page loading.

void Storage_system::format unsigned int    first_block_to_use = 0,
unsigned int    segment_size = 0
 

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!

void Storage_system::init unsigned int    first_block_to_use = 0
 

Initialze this storage system object based on an existing system on disk and perform a recovery if necessary. This is called on boot.

bool Storage_system::is_formatted unsigned int    first_block_to_use = 0
 

void Storage_system::load_page void *    virtual_page
 

Attempt to load the page with the given virtual address. Map the page into memory even if it cannot be found on disk.

unsigned int * Storage_system::load_table Address_map   map,
unsigned int    dir_index
 

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.

unsigned int Storage_system::log_map Address_map   map
 

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.

unsigned int Storage_system::log_page void *    page,
bool    update_block_map = true
 

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.

unsigned int Storage_system::segment_index_to_block unsigned int    segment_index [inline]
 

Convert a segment index to its corresponding disk block address.

void Storage_system::set_device Block_device   device [inline]
 

Set the block device upon which this storage system resides.

void Storage_system::write_segment  
 

Write the current segment to disk and start a new one.

void Storage_system::write_segment_if_full  
 

If the current segment is full, write it to disk and start a new one.

void Storage_system::write_superblock unsigned int    block_directory = 0,
unsigned int    segment_directory = 0,
unsigned int    curr_empty_segment = 0
 

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.


Member Data Documentation

Block_map Storage_system::block_map [protected]
 

keeps track of live pages on disk.

unsigned int Storage_system::blocks_per_page [protected]
 

page size in blocks.

unsigned int Storage_system::blocks_per_segment [protected]
 

segment size in blocks.

unsigned int Storage_system::checkpoint_counter [protected]
 

keeps track of last checkpoint.

Segment Storage_system::curr_segment [protected]
 

current disk segment being used.

unsigned int Storage_system::curr_superblock [protected]
 

where checkpoint will be recorded.

Block_device* Storage_system::disk [protected]
 

disk where this store resides.

bool Storage_system::enabled [protected]
 

whether storage is active.

unsigned int Storage_system::first_block [protected]
 

first block of storage system.

Segment_map Storage_system::segment_map [protected]
 

keeps track of segments usage.


The documentation for this class was generated from the following files:

Torsion Operating System, Copyright (C) 2000-2002 Dan Helfman