39 | | === B.1 Inodes Tree === |
| 39 | === B.1 The Inodes Tree === |
| 40 | |
| 41 | The Inode Tree (that is not a tree, but is actually a Directed Acyclic Graph) represent a subset of file system on device. It is modeled as a bi_party graph, containing two types of nodes are the '''inodes''' and the '''dentries''': |
| 42 | * an '''inode''' represents a file, that can be a directory file or a terminal file. It is implemented by the ''vas_inode_t'' structure. |
| 43 | * a '''dentry''' represents a link from a directory file to another file contained in this directory. It is implemented by the ''vfs_dentry_t'' structure. |
| 44 | The main informations registered in the ''vfs_inode_t'' structure are a ''type'', and a ''mapper'', that implement a cache for the file content. It contains also a set of pointers on the directory entries (only for a directory file), implemented as an hash table, and another set of pointers on the parent directories (only for a terminal file), implemented as a linked list. |
| 45 | The main information registered in the ''vfs_dentry_t'' structure are a local name identifying the linked file. Two dentries in the same directory cannot have the same name, because the pathname identifying a file X is defined by the sequence of local names in the path from the root inode to the inode repesenting the X file. It contains a pointer on the child (linked) inode, and another pointer on the parent directory. |
| 46 | |
| 47 | === B.2 The Mapper === |
| 48 | |
| 49 | A ''mapper_t'' structure is attached to each inode, and contains a partial copy in kernel memory of the file content on device implementing a single file cache. As a file is stored on device as an ordered set of 4 Kbytes pages, this cache is implemented as a three levels radix-tree, indexed by the page index in file. Each entry in this radix-tree is a pointer on a physical page. |
| 50 | * for a '''terminal file''', ALMOS MKH implements an ''on-demand'' policy, and copies a page from device to mapper only when this page is accessed for read or write. |
| 51 | * for a '''directory file''', ALMOS-MKH implements a ''prefetch'' policy'', and copies all the pages from device to mapper at the first access to the directory. |
| 52 | |
| 53 | The FAT itself is copied in the kernel memory, as a dedicated mapper - not attached to a specific inode - contains the pages corresponding to the FAT. ALMOS-MKH implements the "on-demand" policy for this FAT mapper. |
| 54 | |
| 55 | When a file (terminal or directory) is modified, or when the FAT itself is modified, the modification is always done in the corresponding mapper, but the device update policy depends on the mapper type: |
| 56 | * For a '''directory''' mapper, or for the '''FAT''' mapper, the device is immediately updated (write-through policy). |
| 57 | * for a '''terminal''' mapper, the device in not immediately updated. It is only updated when the mapper is destroyed, or after an explicit sync() user syscall. |
| 58 | |
| 59 | === B.3 The File Descriptor === |