nilfs2: update MAINTAINERS file entries fix
[deliverable/linux.git] / Documentation / filesystems / nilfs2.txt
CommitLineData
962281a7
RK
1NILFS2
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/
6aff43f8 31List info: http://vger.kernel.org/vger-lists.html#linux-nilfs
962281a7
RK
32
33Caveats
34=======
35
36Features which NILFS2 does not support yet:
37
38 - atime
39 - extended attributes
40 - POSIX ACLs
41 - quotas
fb6e7113 42 - fsck
962281a7
RK
43 - defragmentation
44
45Mount options
46=============
47
48NILFS2 supports the following mount options:
49(*) == default
50
773bc4f3
RK
51barrier(*) This enables/disables the use of write barriers. This
52nobarrier requires an IO stack which can support barriers, and
53 if nilfs gets an error on a barrier write, it will
54 disable again with a warning.
277a6a34
RK
55errors=continue Keep going on a filesystem error.
56errors=remount-ro(*) Remount the filesystem read-only on an error.
962281a7
RK
57errors=panic Panic and halt the machine if an error occurs.
58cp=n Specify the checkpoint-number of the snapshot to be
59 mounted. Checkpoints and snapshots are listed by lscp
60 user command. Only the checkpoints marked as snapshot
61 are mountable with this option. Snapshot is read-only,
62 so a read-only mount option must be specified together.
63order=relaxed(*) Apply relaxed order semantics that allows modified data
64 blocks to be written to disk without making a
65 checkpoint if no metadata update is going. This mode
66 is equivalent to the ordered data mode of the ext3
67 filesystem except for the updates on data blocks still
68 conserve atomicity. This will improve synchronous
69 write performance for overwriting.
70order=strict Apply strict in-order semantics that preserves sequence
71 of all file operations including overwriting of data
72 blocks. That means, it is guaranteed that no
73 overtaking of events occurs in the recovered file
74 system after a crash.
0234576d
RK
75norecovery Disable recovery of the filesystem on mount.
76 This disables every write access on the device for
77 read-only mounts or snapshots. This option will fail
78 for r/w mounts on an unclean volume.
802d3177
RK
79discard This enables/disables the use of discard/TRIM commands.
80nodiscard(*) The discard/TRIM commands are sent to the underlying
81 block device when blocks are freed. This is useful
82 for SSD devices and sparse/thinly-provisioned LUNs.
962281a7 83
d623a942
VD
84Ioctls
85======
86
87There is some NILFS2 specific functionality which can be accessed by applications
88through the system call interfaces. The list of all NILFS2 specific ioctls are
89shown in the table below.
90
91Table of NILFS2 specific ioctls
92..............................................................................
93 Ioctl Description
94 NILFS_IOCTL_CHANGE_CPMODE Change mode of given checkpoint between
95 checkpoint and snapshot state. This ioctl is
96 used in chcp and mkcp utilities.
97
98 NILFS_IOCTL_DELETE_CHECKPOINT Remove checkpoint from NILFS2 file system.
99 This ioctl is used in rmcp utility.
100
101 NILFS_IOCTL_GET_CPINFO Return info about requested checkpoints. This
102 ioctl is used in lscp utility and by
103 nilfs_cleanerd daemon.
104
105 NILFS_IOCTL_GET_CPSTAT Return checkpoints statistics. This ioctl is
106 used by lscp, rmcp utilities and by
107 nilfs_cleanerd daemon.
108
109 NILFS_IOCTL_GET_SUINFO Return segment usage info about requested
110 segments. This ioctl is used in lssu,
111 nilfs_resize utilities and by nilfs_cleanerd
112 daemon.
113
2cc88f3a
AR
114 NILFS_IOCTL_SET_SUINFO Modify segment usage info of requested
115 segments. This ioctl is used by
116 nilfs_cleanerd daemon to skip unnecessary
117 cleaning operation of segments and reduce
118 performance penalty or wear of flash device
119 due to redundant move of in-use blocks.
120
d623a942
VD
121 NILFS_IOCTL_GET_SUSTAT Return segment usage statistics. This ioctl
122 is used in lssu, nilfs_resize utilities and
123 by nilfs_cleanerd daemon.
124
125 NILFS_IOCTL_GET_VINFO Return information on virtual block addresses.
126 This ioctl is used by nilfs_cleanerd daemon.
127
128 NILFS_IOCTL_GET_BDESCS Return information about descriptors of disk
129 block numbers. This ioctl is used by
130 nilfs_cleanerd daemon.
131
132 NILFS_IOCTL_CLEAN_SEGMENTS Do garbage collection operation in the
133 environment of requested parameters from
134 userspace. This ioctl is used by
135 nilfs_cleanerd daemon.
136
137 NILFS_IOCTL_SYNC Make a checkpoint. This ioctl is used in
138 mkcp utility.
139
140 NILFS_IOCTL_RESIZE Resize NILFS2 volume. This ioctl is used
141 by nilfs_resize utility.
142
143 NILFS_IOCTL_SET_ALLOC_RANGE Define lower limit of segments in bytes and
144 upper limit of segments in bytes. This ioctl
145 is used by nilfs_resize utility.
146
962281a7
RK
147NILFS2 usage
148============
149
150To use nilfs2 as a local file system, simply:
151
152 # mkfs -t nilfs2 /dev/block_device
153 # mount -t nilfs2 /dev/block_device /dir
154
155This will also invoke the cleaner through the mount helper program
156(mount.nilfs2).
157
158Checkpoints and snapshots are managed by the following commands.
159Their manpages are included in the nilfs-utils package above.
160
161 lscp list checkpoints or snapshots.
162 mkcp make a checkpoint or a snapshot.
163 chcp change an existing checkpoint to a snapshot or vice versa.
164 rmcp invalidate specified checkpoint(s).
165
166To mount a snapshot,
167
168 # mount -t nilfs2 -r -o cp=<cno> /dev/block_device /snap_dir
169
170where <cno> is the checkpoint number of the snapshot.
171
172To unmount the NILFS2 mount point or snapshot, simply:
173
174 # umount /dir
175
176Then, the cleaner daemon is automatically shut down by the umount
177helper program (umount.nilfs2).
178
179Disk format
180===========
181
182A nilfs2 volume is equally divided into a number of segments except
183for the super block (SB) and segment #0. A segment is the container
184of logs. Each log is composed of summary information blocks, payload
185blocks, and an optional super root block (SR):
186
187 ______________________________________________________
188 | |SB| | Segment | Segment | Segment | ... | Segment | |
189 |_|__|_|____0____|____1____|____2____|_____|____N____|_|
190 0 +1K +4K +8M +16M +24M +(8MB x N)
191 . . (Typical offsets for 4KB-block)
192 . .
193 .______________________.
194 | log | log |... | log |
195 |__1__|__2__|____|__m__|
196 . .
197 . .
198 . .
199 .______________________________.
200 | Summary | Payload blocks |SR|
201 |_blocks__|_________________|__|
202
203The payload blocks are organized per file, and each file consists of
204data blocks and B-tree node blocks:
205
206 |<--- File-A --->|<--- File-B --->|
207 _______________________________________________________________
208 | Data blocks | B-tree blocks | Data blocks | B-tree blocks | ...
209 _|_____________|_______________|_____________|_______________|_
210
211
212Since only the modified blocks are written in the log, it may have
213files without data blocks or B-tree node blocks.
214
215The organization of the blocks is recorded in the summary information
216blocks, which contains a header structure (nilfs_segment_summary), per
217file structures (nilfs_finfo), and per block structures (nilfs_binfo):
218
219 _________________________________________________________________________
220 | Summary | finfo | binfo | ... | binfo | finfo | binfo | ... | binfo |...
221 |_blocks__|___A___|_(A,1)_|_____|(A,Na)_|___B___|_(B,1)_|_____|(B,Nb)_|___
222
223
224The logs include regular files, directory files, symbolic link files
225and several meta data files. The mata data files are the files used
226to maintain file system meta data. The current version of NILFS2 uses
227the following meta data files:
228
229 1) Inode file (ifile) -- Stores on-disk inodes
230 2) Checkpoint file (cpfile) -- Stores checkpoints
231 3) Segment usage file (sufile) -- Stores allocation state of segments
232 4) Data address translation file -- Maps virtual block numbers to usual
233 (DAT) block numbers. This file serves to
234 make on-disk blocks relocatable.
962281a7
RK
235
236The following figure shows a typical organization of the logs:
237
238 _________________________________________________________________________
239 | Summary | regular file | file | ... | ifile | cpfile | sufile | DAT |SR|
240 |_blocks__|_or_directory_|_______|_____|_______|________|________|_____|__|
241
242
243To stride over segment boundaries, this sequence of files may be split
244into multiple logs. The sequence of logs that should be treated as
245logically one log, is delimited with flags marked in the segment
246summary. The recovery code of nilfs2 looks this boundary information
247to ensure atomicity of updates.
248
249The super root block is inserted for every checkpoints. It includes
250three special inodes, inodes for the DAT, cpfile, and sufile. Inodes
251of regular files, directories, symlinks and other special files, are
252included in the ifile. The inode of ifile itself is included in the
253corresponding checkpoint entry in the cpfile. Thus, the hierarchy
254among NILFS2 files can be depicted as follows:
255
256 Super block (SB)
257 |
258 v
259 Super root block (the latest cno=xx)
260 |-- DAT
261 |-- sufile
262 `-- cpfile
263 |-- ifile (cno=c1)
264 |-- ifile (cno=c2) ---- file (ino=i1)
265 : : |-- file (ino=i2)
266 `-- ifile (cno=xx) |-- file (ino=i3)
267 : :
268 `-- file (ino=yy)
269 ( regular file, directory, or symlink )
270
271For detail on the format of each file, please see include/linux/nilfs2_fs.h.
This page took 0.46877 seconds and 5 git commands to generate.