diff options
| author | Joern Engel <joern@logfs.org> | 2009-11-20 14:13:39 -0500 |
|---|---|---|
| committer | Joern Engel <joern@logfs.org> | 2009-11-20 14:13:39 -0500 |
| commit | 5db53f3e80dee2d9dff5e534f9e9fe1db17c9936 (patch) | |
| tree | 066f2873eeb7eb86466f6389e45892d957db3de2 | |
| parent | 66b00a7c93ec782d118d2c03bd599cfd041e80a1 (diff) | |
[LogFS] add new flash file system
This is a new flash file system. See
Documentation/filesystems/logfs.txt
Signed-off-by: Joern Engel <joern@logfs.org>
| -rw-r--r-- | Documentation/filesystems/00-INDEX | 2 | ||||
| -rw-r--r-- | Documentation/filesystems/logfs.txt | 241 | ||||
| -rw-r--r-- | fs/Kconfig | 1 | ||||
| -rw-r--r-- | fs/Makefile | 1 | ||||
| -rw-r--r-- | fs/logfs/Kconfig | 17 | ||||
| -rw-r--r-- | fs/logfs/Makefile | 13 | ||||
| -rw-r--r-- | fs/logfs/compr.c | 95 | ||||
| -rw-r--r-- | fs/logfs/dev_bdev.c | 263 | ||||
| -rw-r--r-- | fs/logfs/dev_mtd.c | 253 | ||||
| -rw-r--r-- | fs/logfs/dir.c | 818 | ||||
| -rw-r--r-- | fs/logfs/file.c | 263 | ||||
| -rw-r--r-- | fs/logfs/gc.c | 730 | ||||
| -rw-r--r-- | fs/logfs/inode.c | 417 | ||||
| -rw-r--r-- | fs/logfs/journal.c | 879 | ||||
| -rw-r--r-- | fs/logfs/logfs.h | 722 | ||||
| -rw-r--r-- | fs/logfs/logfs_abi.h | 627 | ||||
| -rw-r--r-- | fs/logfs/readwrite.c | 2246 | ||||
| -rw-r--r-- | fs/logfs/segment.c | 924 | ||||
| -rw-r--r-- | fs/logfs/super.c | 634 | ||||
| -rw-r--r-- | include/linux/btree-128.h | 109 | ||||
| -rw-r--r-- | include/linux/btree-type.h | 147 | ||||
| -rw-r--r-- | include/linux/btree.h | 243 | ||||
| -rw-r--r-- | lib/Kconfig | 3 | ||||
| -rw-r--r-- | lib/Makefile | 1 | ||||
| -rw-r--r-- | lib/btree.c | 797 |
25 files changed, 10446 insertions, 0 deletions
diff --git a/Documentation/filesystems/00-INDEX b/Documentation/filesystems/00-INDEX index f15621ee5599..d362aa543b27 100644 --- a/Documentation/filesystems/00-INDEX +++ b/Documentation/filesystems/00-INDEX | |||
| @@ -62,6 +62,8 @@ jfs.txt | |||
| 62 | - info and mount options for the JFS filesystem. | 62 | - info and mount options for the JFS filesystem. |
| 63 | locks.txt | 63 | locks.txt |
| 64 | - info on file locking implementations, flock() vs. fcntl(), etc. | 64 | - info on file locking implementations, flock() vs. fcntl(), etc. |
| 65 | logfs.txt | ||
| 66 | - info on the LogFS flash filesystem. | ||
| 65 | mandatory-locking.txt | 67 | mandatory-locking.txt |
| 66 | - info on the Linux implementation of Sys V mandatory file locking. | 68 | - info on the Linux implementation of Sys V mandatory file locking. |
| 67 | ncpfs.txt | 69 | ncpfs.txt |
diff --git a/Documentation/filesystems/logfs.txt b/Documentation/filesystems/logfs.txt new file mode 100644 index 000000000000..e64c94ba401a --- /dev/null +++ b/Documentation/filesystems/logfs.txt | |||
| @@ -0,0 +1,241 @@ | |||
| 1 | |||
| 2 | The LogFS Flash Filesystem | ||
| 3 | ========================== | ||
| 4 | |||
| 5 | Specification | ||
| 6 | ============= | ||
| 7 | |||
| 8 | Superblocks | ||
| 9 | ----------- | ||
| 10 | |||
| 11 | Two superblocks exist at the beginning and end of the filesystem. | ||
| 12 | Each superblock is 256 Bytes large, with another 3840 Bytes reserved | ||
| 13 | for future purposes, making a total of 4096 Bytes. | ||
| 14 | |||
| 15 | Superblock locations may differ for MTD and block devices. On MTD the | ||
| 16 | first non-bad block contains a superblock in the first 4096 Bytes and | ||
| 17 | the last non-bad block contains a superblock in the last 4096 Bytes. | ||
| 18 | On block devices, the first 4096 Bytes of the device contain the first | ||
| 19 | superblock and the last aligned 4096 Byte-block contains the second | ||
| 20 | superblock. | ||
| 21 | |||
| 22 | For the most part, the superblocks can be considered read-only. They | ||
| 23 | are written only to correct errors detected within the superblocks, | ||
| 24 | move the journal and change the filesystem parameters through tunefs. | ||
| 25 | As a result, the superblock does not contain any fields that require | ||
| 26 | constant updates, like the amount of free space, etc. | ||
| 27 | |||
| 28 | Segments | ||
| 29 | -------- | ||
| 30 | |||
| 31 | The space in the device is split up into equal-sized segments. | ||
| 32 | Segments are the primary write unit of LogFS. Within each segments, | ||
| 33 | writes happen from front (low addresses) to back (high addresses. If | ||
| 34 | only a partial segment has been written, the segment number, the | ||
| 35 | current position within and optionally a write buffer are stored in | ||
| 36 | the journal. | ||
| 37 | |||
| 38 | Segments are erased as a whole. Therefore Garbage Collection may be | ||
| 39 | required to completely free a segment before doing so. | ||
| 40 | |||
| 41 | Journal | ||
| 42 | -------- | ||
| 43 | |||
| 44 | The journal contains all global information about the filesystem that | ||
| 45 | is subject to frequent change. At mount time, it has to be scanned | ||
| 46 | for the most recent commit entry, which contains a list of pointers to | ||
| 47 | all currently valid entries. | ||
| 48 | |||
| 49 | Object Store | ||
| 50 | ------------ | ||
| 51 | |||
| 52 | All space except for the superblocks and journal is part of the object | ||
| 53 | store. Each segment contains a segment header and a number of | ||
| 54 | objects, each consisting of the object header and the payload. | ||
| 55 | Objects are either inodes, directory entries (dentries), file data | ||
| 56 | blocks or indirect blocks. | ||
| 57 | |||
| 58 | Levels | ||
| 59 | ------ | ||
| 60 | |||
| 61 | Garbage collection (GC) may fail if all data is written | ||
| 62 | indiscriminately. One requirement of GC is that data is seperated | ||
| 63 | roughly according to the distance between the tree root and the data. | ||
| 64 | Effectively that means all file data is on level 0, indirect blocks | ||
| 65 | are on levels 1, 2, 3 4 or 5 for 1x, 2x, 3x, 4x or 5x indirect blocks, | ||
| 66 | respectively. Inode file data is on level 6 for the inodes and 7-11 | ||
| 67 | for indirect blocks. | ||
| 68 | |||
| 69 | Each segment contains objects of a single level only. As a result, | ||
| 70 | each level requires its own seperate segment to be open for writing. | ||
| 71 | |||
| 72 | Inode File | ||
| 73 | ---------- | ||
| 74 | |||
| 75 | All inodes are stored in a special file, the inode file. Single | ||
| 76 | exception is the inode file's inode (master inode) which for obvious | ||
| 77 | reasons is stored in the journal instead. Instead of data blocks, the | ||
| 78 | leaf nodes of the inode files are inodes. | ||
| 79 | |||
| 80 | Aliases | ||
| 81 | ------- | ||
| 82 | |||
| 83 | Writes in LogFS are done by means of a wandering tree. A naïve | ||
| 84 | implementation would require that for each write or a block, all | ||
| 85 | parent blocks are written as well, since the block pointers have | ||
| 86 | changed. Such an implementation would not be very efficient. | ||
| 87 | |||
| 88 | In LogFS, the block pointer changes are cached in the journal by means | ||
| 89 | of alias entries. Each alias consists of its logical address - inode | ||
| 90 | number, block index, level and child number (index into block) - and | ||
| 91 | the changed data. Any 8-byte word can be changes in this manner. | ||
| 92 | |||
| 93 | Currently aliases are used for block pointers, file size, file used | ||
| 94 | bytes and the height of an inodes indirect tree. | ||
| 95 | |||
| 96 | Segment Aliases | ||
| 97 | --------------- | ||
| 98 | |||
| 99 | Related to regular aliases, these are used to handle bad blocks. | ||
| 100 | Initially, bad blocks are handled by moving the affected segment | ||
| 101 | content to a spare segment and noting this move in the journal with a | ||
| 102 | segment alias, a simple (to, from) tupel. GC will later empty this | ||
| 103 | segment and the alias can be removed again. This is used on MTD only. | ||
| 104 | |||
| 105 | Vim | ||
| 106 | --- | ||
| 107 | |||
| 108 | By cleverly predicting the life time of data, it is possible to | ||
| 109 | seperate long-living data from short-living data and thereby reduce | ||
| 110 | the GC overhead later. Each type of distinc life expectency (vim) can | ||
| 111 | have a seperate segment open for writing. Each (level, vim) tupel can | ||
| 112 | be open just once. If an open segment with unknown vim is encountered | ||
| 113 | at mount time, it is closed and ignored henceforth. | ||
| 114 | |||
| 115 | Indirect Tree | ||
| 116 | ------------- | ||
| 117 | |||
| 118 | Inodes in LogFS are similar to FFS-style filesystems with direct and | ||
| 119 | indirect block pointers. One difference is that LogFS uses a single | ||
| 120 | indirect pointer that can be either a 1x, 2x, etc. indirect pointer. | ||
| 121 | A height field in the inode defines the height of the indirect tree | ||
| 122 | and thereby the indirection of the pointer. | ||
| 123 | |||
| 124 | Another difference is the addressing of indirect blocks. In LogFS, | ||
| 125 | the first 16 pointers in the first indirect block are left empty, | ||
| 126 | corresponding to the 16 direct pointers in the inode. In ext2 (maybe | ||
| 127 | others as well) the first pointer in the first indirect block | ||
| 128 | corresponds to logical block 12, skipping the 12 direct pointers. | ||
| 129 | So where ext2 is using arithmetic to better utilize space, LogFS keeps | ||
| 130 | arithmetic simple and uses compression to save space. | ||
| 131 | |||
| 132 | Compression | ||
| 133 | ----------- | ||
| 134 | |||
| 135 | Both file data and metadata can be compressed. Compression for file | ||
| 136 | data can be enabled with chattr +c and disabled with chattr -c. Doing | ||
