Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[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
114 NILFS_IOCTL_GET_SUSTAT Return segment usage statistics. This ioctl
115 is used in lssu, nilfs_resize utilities and
116 by nilfs_cleanerd daemon.
117
118 NILFS_IOCTL_GET_VINFO Return information on virtual block addresses.
119 This ioctl is used by nilfs_cleanerd daemon.
120
121 NILFS_IOCTL_GET_BDESCS Return information about descriptors of disk
122 block numbers. This ioctl is used by
123 nilfs_cleanerd daemon.
124
125 NILFS_IOCTL_CLEAN_SEGMENTS Do garbage collection operation in the
126 environment of requested parameters from
127 userspace. This ioctl is used by
128 nilfs_cleanerd daemon.
129
130 NILFS_IOCTL_SYNC Make a checkpoint. This ioctl is used in
131 mkcp utility.
132
133 NILFS_IOCTL_RESIZE Resize NILFS2 volume. This ioctl is used
134 by nilfs_resize utility.
135
136 NILFS_IOCTL_SET_ALLOC_RANGE Define lower limit of segments in bytes and
137 upper limit of segments in bytes. This ioctl
138 is used by nilfs_resize utility.
139
962281a7
RK
140NILFS2 usage
141============
142
143To use nilfs2 as a local file system, simply:
144
145 # mkfs -t nilfs2 /dev/block_device
146 # mount -t nilfs2 /dev/block_device /dir
147
148This will also invoke the cleaner through the mount helper program
149(mount.nilfs2).
150
151Checkpoints and snapshots are managed by the following commands.
152Their manpages are included in the nilfs-utils package above.
153
154 lscp list checkpoints or snapshots.
155 mkcp make a checkpoint or a snapshot.
156 chcp change an existing checkpoint to a snapshot or vice versa.
157 rmcp invalidate specified checkpoint(s).
158
159To mount a snapshot,
160
161 # mount -t nilfs2 -r -o cp=<cno> /dev/block_device /snap_dir
162
163where <cno> is the checkpoint number of the snapshot.
164
165To unmount the NILFS2 mount point or snapshot, simply:
166
167 # umount /dir
168
169Then, the cleaner daemon is automatically shut down by the umount
170helper program (umount.nilfs2).
171
172Disk format
173===========
174
175A nilfs2 volume is equally divided into a number of segments except
176for the super block (SB) and segment #0. A segment is the container
177of logs. Each log is composed of summary information blocks, payload
178blocks, and an optional super root block (SR):
179
180 ______________________________________________________
181 | |SB| | Segment | Segment | Segment | ... | Segment | |
182 |_|__|_|____0____|____1____|____2____|_____|____N____|_|
183 0 +1K +4K +8M +16M +24M +(8MB x N)
184 . . (Typical offsets for 4KB-block)
185 . .
186 .______________________.
187 | log | log |... | log |
188 |__1__|__2__|____|__m__|
189 . .
190 . .
191 . .
192 .______________________________.
193 | Summary | Payload blocks |SR|
194 |_blocks__|_________________|__|
195
196The payload blocks are organized per file, and each file consists of
197data blocks and B-tree node blocks:
198
199 |<--- File-A --->|<--- File-B --->|
200 _______________________________________________________________
201 | Data blocks | B-tree blocks | Data blocks | B-tree blocks | ...
202 _|_____________|_______________|_____________|_______________|_
203
204
205Since only the modified blocks are written in the log, it may have
206files without data blocks or B-tree node blocks.
207
208The organization of the blocks is recorded in the summary information
209blocks, which contains a header structure (nilfs_segment_summary), per
210file structures (nilfs_finfo), and per block structures (nilfs_binfo):
211
212 _________________________________________________________________________
213 | Summary | finfo | binfo | ... | binfo | finfo | binfo | ... | binfo |...
214 |_blocks__|___A___|_(A,1)_|_____|(A,Na)_|___B___|_(B,1)_|_____|(B,Nb)_|___
215
216
217The logs include regular files, directory files, symbolic link files
218and several meta data files. The mata data files are the files used
219to maintain file system meta data. The current version of NILFS2 uses
220the following meta data files:
221
222 1) Inode file (ifile) -- Stores on-disk inodes
223 2) Checkpoint file (cpfile) -- Stores checkpoints
224 3) Segment usage file (sufile) -- Stores allocation state of segments
225 4) Data address translation file -- Maps virtual block numbers to usual
226 (DAT) block numbers. This file serves to
227 make on-disk blocks relocatable.
962281a7
RK
228
229The following figure shows a typical organization of the logs:
230
231 _________________________________________________________________________
232 | Summary | regular file | file | ... | ifile | cpfile | sufile | DAT |SR|
233 |_blocks__|_or_directory_|_______|_____|_______|________|________|_____|__|
234
235
236To stride over segment boundaries, this sequence of files may be split
237into multiple logs. The sequence of logs that should be treated as
238logically one log, is delimited with flags marked in the segment
239summary. The recovery code of nilfs2 looks this boundary information
240to ensure atomicity of updates.
241
242The super root block is inserted for every checkpoints. It includes
243three special inodes, inodes for the DAT, cpfile, and sufile. Inodes
244of regular files, directories, symlinks and other special files, are
245included in the ifile. The inode of ifile itself is included in the
246corresponding checkpoint entry in the cpfile. Thus, the hierarchy
247among NILFS2 files can be depicted as follows:
248
249 Super block (SB)
250 |
251 v
252 Super root block (the latest cno=xx)
253 |-- DAT
254 |-- sufile
255 `-- cpfile
256 |-- ifile (cno=c1)
257 |-- ifile (cno=c2) ---- file (ino=i1)
258 : : |-- file (ino=i2)
259 `-- ifile (cno=xx) |-- file (ino=i3)
260 : :
261 `-- file (ino=yy)
262 ( regular file, directory, or symlink )
263
264For detail on the format of each file, please see include/linux/nilfs2_fs.h.
This page took 0.325395 seconds and 5 git commands to generate.