Architecture overview of file system
Drivers for FUSE on Linux, and Dokan on Windows. File system is contained in a growable file — maintainance of this file is handled by the lowest layer.
This layer handles file system startup and integration with the FUSE and Dokan drivers.
Supports basic file and directory operations. FUSE and Dokan specify a number of operations that file system implementations can support. These correspond closely with the OS calls that applications can make for file manipulation.
This layer has knowledge of how file data and metadata is stored in the file system. Files and directories are stored as collection of keys. Each file or directory has a unique id; this becomes the prefix for the keys of its metadata.
File data is stored in extents (sequences of contiguous blocks), each of which is recorded by a key of the form prefix/Xstart-end. This indicates that blocks start to end of file prefix are located in file system blocks starting at that key’s value.
The file system contains a single B-tree. Each key (a variable-length sequence of bytes), has a type and a value (a single 4-byte datum).
This layer provides a generic tree-traversal function. Operations on individual keys are atomic; the traversal function takes a callback that operates on the key when found. If the key is altered, maintenance operations such as splitting and merging are performed automatically after the callback is run.
Several predefined callbacks exist, for adding, deleting, and updating an existing key.
The file system file is divided into fixed-size blocks. The block types are:
Blocks in the cache are indexed two ways: in a hash table by position in the file, and in a LRU linked list. A block can be pinned, indicating it’s in use by some operation and should not be discarded from the cache.
Free blocks are recorded in bitmaps. The super block contains a list of addresses of bitmap blocks. Allocation of a new block begins at a target address (typically closest to related blocks, such as neighbouring parts of the file or tree blocks). The bitmap is searched from that point until a free block is found. Additionally, blocks can be allocated at the end of the file system data file.
This layer implements the .FS virtual directory in the file system root. Under this directory are virtual items that indicate the underlying structure. For instance .FS/keys contains a directory for each prefix, and in each a file for each key starting with that prefix containing the key’s value.
This layer simply handled opening and closing of the file system data file. When the data file is created, it bootstraps the super block and root tree block.
Adblock