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