nilfs2.txt 8.1 KB

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