]>
Commit | Line | Data |
---|---|---|
962281a7 RK |
1 | NILFS2 |
2 | ------ | |
3 | ||
4 | NILFS2 is a log-structured file system (LFS) supporting continuous | |
5 | snapshotting. In addition to versioning capability of the entire file | |
6 | system, users can even restore files mistakenly overwritten or | |
7 | destroyed just a few seconds ago. Since NILFS2 can keep consistency | |
8 | like conventional LFS, it achieves quick recovery after system | |
9 | crashes. | |
10 | ||
11 | NILFS2 creates a number of checkpoints every few seconds or per | |
12 | synchronous write basis (unless there is no change). Users can select | |
13 | significant versions among continuously created checkpoints, and can | |
14 | change them into snapshots which will be preserved until they are | |
15 | changed back to checkpoints. | |
16 | ||
17 | There is no limit on the number of snapshots until the volume gets | |
18 | full. Each snapshot is mountable as a read-only file system | |
19 | concurrently with its writable mount, and this feature is convenient | |
20 | for online backup. | |
21 | ||
22 | The userland tools are included in nilfs-utils package, which is | |
23 | available from the following download page. At least "mkfs.nilfs2", | |
24 | "mount.nilfs2", "umount.nilfs2", and "nilfs_cleanerd" (so called | |
25 | cleaner or garbage collector) are required. Details on the tools are | |
26 | described in the man pages included in the package. | |
27 | ||
28 | Project web page: http://www.nilfs.org/en/ | |
29 | Download page: http://www.nilfs.org/en/download.html | |
30 | Git tree web page: http://www.nilfs.org/git/ | |
31 | NILFS mailing lists: http://www.nilfs.org/mailman/listinfo/users | |
32 | ||
33 | Caveats | |
34 | ======= | |
35 | ||
36 | Features which NILFS2 does not support yet: | |
37 | ||
38 | - atime | |
39 | - extended attributes | |
40 | - POSIX ACLs | |
41 | - quotas | |
fb6e7113 RK |
42 | - fsck |
43 | - resize | |
962281a7 RK |
44 | - defragmentation |
45 | ||
46 | Mount options | |
47 | ============= | |
48 | ||
49 | NILFS2 supports the following mount options: | |
50 | (*) == default | |
51 | ||
52 | barrier=on(*) This enables/disables barriers. barrier=off disables | |
53 | it, barrier=on enables it. | |
54 | errors=continue(*) Keep going on a filesystem error. | |
55 | errors=remount-ro Remount the filesystem read-only on an error. | |
56 | errors=panic Panic and halt the machine if an error occurs. | |
57 | cp=n Specify the checkpoint-number of the snapshot to be | |
58 | mounted. Checkpoints and snapshots are listed by lscp | |
59 | user command. Only the checkpoints marked as snapshot | |
60 | are mountable with this option. Snapshot is read-only, | |
61 | so a read-only mount option must be specified together. | |
62 | order=relaxed(*) Apply relaxed order semantics that allows modified data | |
63 | blocks to be written to disk without making a | |
64 | checkpoint if no metadata update is going. This mode | |
65 | is equivalent to the ordered data mode of the ext3 | |
66 | filesystem except for the updates on data blocks still | |
67 | conserve atomicity. This will improve synchronous | |
68 | write performance for overwriting. | |
69 | order=strict Apply strict in-order semantics that preserves sequence | |
70 | of all file operations including overwriting of data | |
71 | blocks. That means, it is guaranteed that no | |
72 | overtaking of events occurs in the recovered file | |
73 | system after a crash. | |
74 | ||
75 | NILFS2 usage | |
76 | ============ | |
77 | ||
78 | To use nilfs2 as a local file system, simply: | |
79 | ||
80 | # mkfs -t nilfs2 /dev/block_device | |
81 | # mount -t nilfs2 /dev/block_device /dir | |
82 | ||
83 | This will also invoke the cleaner through the mount helper program | |
84 | (mount.nilfs2). | |
85 | ||
86 | Checkpoints and snapshots are managed by the following commands. | |
87 | Their manpages are included in the nilfs-utils package above. | |
88 | ||
89 | lscp list checkpoints or snapshots. | |
90 | mkcp make a checkpoint or a snapshot. | |
91 | chcp change an existing checkpoint to a snapshot or vice versa. | |
92 | rmcp invalidate specified checkpoint(s). | |
93 | ||
94 | To mount a snapshot, | |
95 | ||
96 | # mount -t nilfs2 -r -o cp=<cno> /dev/block_device /snap_dir | |
97 | ||
98 | where <cno> is the checkpoint number of the snapshot. | |
99 | ||
100 | To unmount the NILFS2 mount point or snapshot, simply: | |
101 | ||
102 | # umount /dir | |
103 | ||
104 | Then, the cleaner daemon is automatically shut down by the umount | |
105 | helper program (umount.nilfs2). | |
106 | ||
107 | Disk format | |
108 | =========== | |
109 | ||
110 | A nilfs2 volume is equally divided into a number of segments except | |
111 | for the super block (SB) and segment #0. A segment is the container | |
112 | of logs. Each log is composed of summary information blocks, payload | |
113 | blocks, and an optional super root block (SR): | |
114 | ||
115 | ______________________________________________________ | |
116 | | |SB| | Segment | Segment | Segment | ... | Segment | | | |
117 | |_|__|_|____0____|____1____|____2____|_____|____N____|_| | |
118 | 0 +1K +4K +8M +16M +24M +(8MB x N) | |
119 | . . (Typical offsets for 4KB-block) | |
120 | . . | |
121 | .______________________. | |
122 | | log | log |... | log | | |
123 | |__1__|__2__|____|__m__| | |
124 | . . | |
125 | . . | |
126 | . . | |
127 | .______________________________. | |
128 | | Summary | Payload blocks |SR| | |
129 | |_blocks__|_________________|__| | |
130 | ||
131 | The payload blocks are organized per file, and each file consists of | |
132 | data blocks and B-tree node blocks: | |
133 | ||
134 | |<--- File-A --->|<--- File-B --->| | |
135 | _______________________________________________________________ | |
136 | | Data blocks | B-tree blocks | Data blocks | B-tree blocks | ... | |
137 | _|_____________|_______________|_____________|_______________|_ | |
138 | ||
139 | ||
140 | Since only the modified blocks are written in the log, it may have | |
141 | files without data blocks or B-tree node blocks. | |
142 | ||
143 | The organization of the blocks is recorded in the summary information | |
144 | blocks, which contains a header structure (nilfs_segment_summary), per | |
145 | file structures (nilfs_finfo), and per block structures (nilfs_binfo): | |
146 | ||
147 | _________________________________________________________________________ | |
148 | | Summary | finfo | binfo | ... | binfo | finfo | binfo | ... | binfo |... | |
149 | |_blocks__|___A___|_(A,1)_|_____|(A,Na)_|___B___|_(B,1)_|_____|(B,Nb)_|___ | |
150 | ||
151 | ||
152 | The logs include regular files, directory files, symbolic link files | |
153 | and several meta data files. The mata data files are the files used | |
154 | to maintain file system meta data. The current version of NILFS2 uses | |
155 | the following meta data files: | |
156 | ||
157 | 1) Inode file (ifile) -- Stores on-disk inodes | |
158 | 2) Checkpoint file (cpfile) -- Stores checkpoints | |
159 | 3) Segment usage file (sufile) -- Stores allocation state of segments | |
160 | 4) Data address translation file -- Maps virtual block numbers to usual | |
161 | (DAT) block numbers. This file serves to | |
162 | make on-disk blocks relocatable. | |
962281a7 RK |
163 | |
164 | The following figure shows a typical organization of the logs: | |
165 | ||
166 | _________________________________________________________________________ | |
167 | | Summary | regular file | file | ... | ifile | cpfile | sufile | DAT |SR| | |
168 | |_blocks__|_or_directory_|_______|_____|_______|________|________|_____|__| | |
169 | ||
170 | ||
171 | To stride over segment boundaries, this sequence of files may be split | |
172 | into multiple logs. The sequence of logs that should be treated as | |
173 | logically one log, is delimited with flags marked in the segment | |
174 | summary. The recovery code of nilfs2 looks this boundary information | |
175 | to ensure atomicity of updates. | |
176 | ||
177 | The super root block is inserted for every checkpoints. It includes | |
178 | three special inodes, inodes for the DAT, cpfile, and sufile. Inodes | |
179 | of regular files, directories, symlinks and other special files, are | |
180 | included in the ifile. The inode of ifile itself is included in the | |
181 | corresponding checkpoint entry in the cpfile. Thus, the hierarchy | |
182 | among NILFS2 files can be depicted as follows: | |
183 | ||
184 | Super block (SB) | |
185 | | | |
186 | v | |
187 | Super root block (the latest cno=xx) | |
188 | |-- DAT | |
189 | |-- sufile | |
190 | `-- cpfile | |
191 | |-- ifile (cno=c1) | |
192 | |-- ifile (cno=c2) ---- file (ino=i1) | |
193 | : : |-- file (ino=i2) | |
194 | `-- ifile (cno=xx) |-- file (ino=i3) | |
195 | : : | |
196 | `-- file (ino=yy) | |
197 | ( regular file, directory, or symlink ) | |
198 | ||
199 | For detail on the format of each file, please see include/linux/nilfs2_fs.h. |