About Kernel Documentation Linux Kernel Contact Linux Resources Linux Blog

Documentation / filesystems / nilfs2.txt




Custom Search

Based on kernel version 2.6.34. Page generated on 2010-05-31 16:02 EST.

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	List info:           http://vger.kernel.org/vger-lists.html#linux-nilfs
32	
33	Caveats
34	=======
35	
36	Features which NILFS2 does not support yet:
37	
38		- atime
39		- extended attributes
40		- POSIX ACLs
41		- quotas
42		- fsck
43		- resize
44		- defragmentation
45	
46	Mount options
47	=============
48	
49	NILFS2 supports the following mount options:
50	(*) == default
51	
52	nobarrier		Disables barriers.
53	errors=continue(*)	Keep going on a filesystem error.
54	errors=remount-ro	Remount the filesystem read-only on an error.
55	errors=panic		Panic and halt the machine if an error occurs.
56	cp=n			Specify the checkpoint-number of the snapshot to be
57				mounted.  Checkpoints and snapshots are listed by lscp
58				user command.  Only the checkpoints marked as snapshot
59				are mountable with this option.  Snapshot is read-only,
60				so a read-only mount option must be specified together.
61	order=relaxed(*)	Apply relaxed order semantics that allows modified data
62				blocks to be written to disk without making a
63				checkpoint if no metadata update is going.  This mode
64				is equivalent to the ordered data mode of the ext3
65				filesystem except for the updates on data blocks still
66				conserve atomicity.  This will improve synchronous
67				write performance for overwriting.
68	order=strict		Apply strict in-order semantics that preserves sequence
69				of all file operations including overwriting of data
70				blocks.  That means, it is guaranteed that no
71				overtaking of events occurs in the recovered file
72				system after a crash.
73	norecovery		Disable recovery of the filesystem on mount.
74				This disables every write access on the device for
75				read-only mounts or snapshots.  This option will fail
76				for r/w mounts on an unclean volume.
77	discard			Issue discard/TRIM commands to the underlying block
78				device when blocks are freed.  This is useful for SSD
79				devices and sparse/thinly-provisioned LUNs.
80	
81	NILFS2 usage
82	============
83	
84	To use nilfs2 as a local file system, simply:
85	
86	 # mkfs -t nilfs2 /dev/block_device
87	 # mount -t nilfs2 /dev/block_device /dir
88	
89	This will also invoke the cleaner through the mount helper program
90	(mount.nilfs2).
91	
92	Checkpoints and snapshots are managed by the following commands.
93	Their manpages are included in the nilfs-utils package above.
94	
95	  lscp     list checkpoints or snapshots.
96	  mkcp     make a checkpoint or a snapshot.
97	  chcp     change an existing checkpoint to a snapshot or vice versa.
98	  rmcp     invalidate specified checkpoint(s).
99	
100	To mount a snapshot,
101	
102	 # mount -t nilfs2 -r -o cp=<cno> /dev/block_device /snap_dir
103	
104	where <cno> is the checkpoint number of the snapshot.
105	
106	To unmount the NILFS2 mount point or snapshot, simply:
107	
108	 # umount /dir
109	
110	Then, the cleaner daemon is automatically shut down by the umount
111	helper program (umount.nilfs2).
112	
113	Disk format
114	===========
115	
116	A nilfs2 volume is equally divided into a number of segments except
117	for the super block (SB) and segment #0.  A segment is the container
118	of logs.  Each log is composed of summary information blocks, payload
119	blocks, and an optional super root block (SR):
120	
121	   ______________________________________________________
122	  | |SB| | Segment | Segment | Segment | ... | Segment | |
123	  |_|__|_|____0____|____1____|____2____|_____|____N____|_|
124	  0 +1K +4K       +8M       +16M      +24M  +(8MB x N)
125	       .             .            (Typical offsets for 4KB-block)
126	    .                  .
127	  .______________________.
128	  | log | log |... | log |
129	  |__1__|__2__|____|__m__|
130	        .       .
131	      .               .
132	    .                       .
133	  .______________________________.
134	  | Summary | Payload blocks  |SR|
135	  |_blocks__|_________________|__|
136	
137	The payload blocks are organized per file, and each file consists of
138	data blocks and B-tree node blocks:
139	
140	    |<---       File-A        --->|<---       File-B        --->|
141	   _______________________________________________________________
142	    | Data blocks | B-tree blocks | Data blocks | B-tree blocks | ...
143	   _|_____________|_______________|_____________|_______________|_
144	
145	
146	Since only the modified blocks are written in the log, it may have
147	files without data blocks or B-tree node blocks.
148	
149	The organization of the blocks is recorded in the summary information
150	blocks, which contains a header structure (nilfs_segment_summary), per
151	file structures (nilfs_finfo), and per block structures (nilfs_binfo):
152	
153	  _________________________________________________________________________
154	 | Summary | finfo | binfo | ... | binfo | finfo | binfo | ... | binfo |...
155	 |_blocks__|___A___|_(A,1)_|_____|(A,Na)_|___B___|_(B,1)_|_____|(B,Nb)_|___
156	
157	
158	The logs include regular files, directory files, symbolic link files
159	and several meta data files.  The mata data files are the files used
160	to maintain file system meta data.  The current version of NILFS2 uses
161	the following meta data files:
162	
163	 1) Inode file (ifile)             -- Stores on-disk inodes
164	 2) Checkpoint file (cpfile)       -- Stores checkpoints
165	 3) Segment usage file (sufile)    -- Stores allocation state of segments
166	 4) Data address translation file  -- Maps virtual block numbers to usual
167	    (DAT)                             block numbers.  This file serves to
168	                                      make on-disk blocks relocatable.
169	
170	The following figure shows a typical organization of the logs:
171	
172	  _________________________________________________________________________
173	 | Summary | regular file | file  | ... | ifile | cpfile | sufile | DAT |SR|
174	 |_blocks__|_or_directory_|_______|_____|_______|________|________|_____|__|
175	
176	
177	To stride over segment boundaries, this sequence of files may be split
178	into multiple logs.  The sequence of logs that should be treated as
179	logically one log, is delimited with flags marked in the segment
180	summary.  The recovery code of nilfs2 looks this boundary information
181	to ensure atomicity of updates.
182	
183	The super root block is inserted for every checkpoints.  It includes
184	three special inodes, inodes for the DAT, cpfile, and sufile.  Inodes
185	of regular files, directories, symlinks and other special files, are
186	included in the ifile.  The inode of ifile itself is included in the
187	corresponding checkpoint entry in the cpfile.  Thus, the hierarchy
188	among NILFS2 files can be depicted as follows:
189	
190	  Super block (SB)
191	       |
192	       v
193	  Super root block (the latest cno=xx)
194	       |-- DAT
195	       |-- sufile
196	       `-- cpfile
197	              |-- ifile (cno=c1)
198	              |-- ifile (cno=c2) ---- file (ino=i1)
199	              :        :          |-- file (ino=i2)
200	              `-- ifile (cno=xx)  |-- file (ino=i3)
201	                                  :        :
202	                                  `-- file (ino=yy)
203	                                    ( regular file, directory, or symlink )
204	
205	For detail on the format of each file, please see include/linux/nilfs2_fs.h.
Hide Line Numbers
About Kernel Documentation Linux Kernel Contact Linux Resources Linux Blog

Information is copyright its respective author. All material is available from the Linux Kernel Source distributed under a GPL License. This page is provided as a free service by mjmwired.net.