=========================================================
ϡ
Linux-3.4.1/Documentation/filesystems/nilfs2.txt Ǥ
Ρ JF ץ < http://linuxjf.sourceforge.jp/ >
  2012/09/05
  Seiji Kaneko < skaneko at a2 dot mbn dot or dot jp >
=========================================================
NILFS2
------

#NILFS2 is a log-structured file system (LFS) supporting continuous
#snapshotting.  In addition to versioning capability of the entire file
#system, users can even restore files mistakenly overwritten or
#destroyed just a few seconds ago.  Since NILFS2 can keep consistency
#like conventional LFS, it achieves quick recovery after system
#crashes.
NILFS2 Ϣ³ʥåץåȤ򥵥ݡȤ¤ե륷
 (LFS) Ǥե륷ƥΤФСǽ˲ä
˸äƾ񤭤˲եβԤȤ
ǽǤNILFS2 Ͻ LFS Τ褦˰ݤĵǽäƤޤ
顢ƥ९åᤤ¸Ƥޤ

#NILFS2 creates a number of checkpoints every few seconds or per
#synchronous write basis (unless there is no change).  Users can select
#significant versions among continuously created checkpoints, and can
#change them into snapshots which will be preserved until they are
#changed back to checkpoints.
NILFS2 Ͽˡ뤤Ʊ񤭹ߤ (ѹʤ
) ¿ΥåݥȤƤޤ桼Ϸ³Ū˺
줿åݥȤɬפȤС򤷡ΥС
򥹥ʥåץåȤѴǤޤʥåץåȤϥåݥ
Ȥᤵޤݻޤ

#There is no limit on the number of snapshots until the volume gets
#full.  Each snapshot is mountable as a read-only file system
#concurrently with its writable mount, and this feature is convenient
#for online backup.
ܥ塼बդˤʤʤ¤ꡢʥåץåȿ¤Ϥ
󡣳ƥʥåץåȤϥ꡼ɥ꡼Υե륷ƥȤơ
񤭹߲ǽʥޥȤƱ˥ޥȲǽǤꡢϥ饤
ХååפͭѤʵǽǤ

#The userland tools are included in nilfs-utils package, which is
#available from the following download page.  At least "mkfs.nilfs2",
#"mount.nilfs2", "umount.nilfs2", and "nilfs_cleanerd" (so called
#cleaner or garbage collector) are required.  Details on the tools are
#described in the man pages included in the package.
ʲΥɥڡ󶡤Ƥ nilfs-utils ѥå
桼ɥġ뤬ϿƤޤʤȤ⡢"mkfs.nilfs2"
"mount.nilfs2""umount.nilfs2"  "nilfs_cleanerd" (Х꡼
ʷ󥬥١쥯) ɬפǤΥġξܺ٤ϡѥå
ƱƤ man ڡ˵ܤޤ

#Project web page:    http://www.nilfs.org/en/
#Download page:       http://www.nilfs.org/en/download.html
#Git tree web page:   http://www.nilfs.org/git/
#List info            http://vger.kernel.org/vger-lists.html#linux-nilfs
ץȥ֥ڡ: http://www.nilfs.org/en/
ɥڡ:       http://www.nilfs.org/en/download.html
Git ĥ꡼֥ڡ:   http://www.nilfs.org/git/
᡼󥰥ꥹ          http://vger.kernel.org/vger-lists.html#linux-nilfs

#Caveats
#=======
Ǥ
=======

#Features which NILFS2 does not support yet:
NILFS2 ޤݡȤƤʤǽϰʲΤȤǤ

#	- atime
#	- extended attributes
#	- POSIX ACLs
#	- quotas
#	- fsck
#	- defragmentation
	- atime
	- ĥȥӥ塼
	- POSIX ACL
	- 
	- fsck
	- ǥե饰

#Mount options
#=============
ޥȥץ
=================

#NILFS2 supports the following mount options:
#(*) == default
NILFS2 ϰʲΥޥȥץ򥵥ݡȤƤޤ
(*)  ɸ

#barrier(*)		This enables/disables the use of write barriers.  This
#nobarrier		requires an IO stack which can support barriers, and
#			if nilfs gets an error on a barrier write, it will
#			disable again with a warning.
#errors=continue		Keep going on a filesystem error.
#errors=remount-ro(*)	Remount the filesystem read-only on an error.
#errors=panic		Panic and halt the machine if an error occurs.
#cp=n			Specify the checkpoint-number of the snapshot to be
#			mounted.  Checkpoints and snapshots are listed by lscp
#			user command.  Only the checkpoints marked as snapshot
#			are mountable with this option.  Snapshot is read-only,
#			so a read-only mount option must be specified together.
#order=relaxed(*)	Apply relaxed order semantics that allows modified data
#			blocks to be written to disk without making a
#			checkpoint if no metadata update is going.  This mode
#			is equivalent to the ordered data mode of the ext3
#			filesystem except for the updates on data blocks still
#			conserve atomicity.  This will improve synchronous
#			write performance for overwriting.
#order=strict		Apply strict in-order semantics that preserves sequence
#			of all file operations including overwriting of data
#			blocks.  That means, it is guaranteed that no
#			overtaking of events occurs in the recovered file
#			system after a crash.
#norecovery		Disable recovery of the filesystem on mount.
#			This disables every write access on the device for
#			read-only mounts or snapshots.  This option will fail
#			for r/w mounts on an unclean volume.
barrier(*)		񤭹ߥХꥢͭ/̵롣εǽˤ
nobarrier		񤭹ߥХꥢ򥵥ݡȤ I/O åɬפǡ
			Хꥢդ񤭹ߤ nilfs 顼
			ϷٹåФƽ񤭤ߥХꥢ̵
			롣
errors=continue		ե륷ƥ२顼˽³Ԥ롣
errors=remount-ro(*)	顼˥ե륷ƥ꡼ɥ꡼Ǻ
			ޥȤ롣
errors=panic		顼˥ѥ˥åȤޥưߤ롣
cp=n			ޥоݤȤ륹ʥåץåȤΥåݥ
			ֹꤹ롣åݥȤȥʥåץ
			åȤ lscp ޥɤǰǽǤ롣ʥåץ
			åȤȤƥޡåݥȤΤߤ
			ץǥޥȲǽǤ롣ʥåץåȤ
			ɤ߽ФΤߤΤᡢɤ߽ФΤߤΥޥȥ
			碌ƻؼɬפ롣
order=relaxed(*)	᥿ǡѹȼʤ硢ѹ줿ǡ
			ååݥȤ뤳Ȥʤ˥ǥ
			˽񤭹¤줿Ѥ롣
			Υ⡼ɤϥǡ֥åιΥȥߥå
			ݻƤƤ ext3 ե륷ƥ
			ordered ⡼ɤ롣Υ⡼ɤˤꡢ
			񤭻Ʊ񤭹ǽ夹롣
order=strict		ǡ֥åؤξ񤭤ޤƤΥե
			ν򡢽ɤ˸̩˹Ԥ
			Ѥ롣ˤꡢåβ줿
			ե륷ƥǥ٥ȤɤȴȯƤ
			ʤȤݾڤ롣
norecovery		ޥȻΥե륷ƥΥꥫХ̵롣
			Υץϡɤ߽ФѤΥޥȤӥ
			åץåȤǤΡ٤ƤΥǥХν񤭹ߤ޻ߤ롣
			Υץ򥯥꡼Ǥʤɤ߽񤭲ǽʥޥ
			ȤФƻꤷ硢Ԥ롣
#discard			This enables/disables the use of discard/TRIM commands.
#nodiscard(*)		The discard/TRIM commands are sent to the underlying
#			block device when blocks are freed.  This is useful
#			for SSD devices and sparse/thinly-provisioned LUNs.
discard			discard/TRIM ޥɤѤͭ/̵롣
nodiscard(*)		discard/TRIM ޥɤϡ֥åγ̥֥
			åФȯԤ롣 SSD 䥹ѡե
			/ץӥ˥󥰤ѤƤ LUN ͭפʥ
			ץǤ롣

#NILFS2 usage
#============
NILFS2 ˡ
==============

#To use nilfs2 as a local file system, simply:
ե륷ƥȤ nilfs2 Ѥˤϡñ˰ʲΤ褦ˤ


# mkfs -t nilfs2 /dev/block_device
# mount -t nilfs2 /dev/block_device /dir

#This will also invoke the cleaner through the mount helper program
#(mount.nilfs2).
νǤƱ˥ޥȥإѡץ (mount.nilfs2) ˤꥯ꡼
ʤưޤ

#Checkpoints and snapshots are managed by the following commands.
#Their manpages are included in the nilfs-utils package above.
åݥȤȥʥåץåȤϰʲΥޥɤǴޤ
ޥɤ man ڡϾ嵭 nilfs-utils ˼ϿƤޤ

#  lscp     list checkpoints or snapshots.
#  mkcp     make a checkpoint or a snapshot.
#  chcp     change an existing checkpoint to a snapshot or vice versa.
#  rmcp     invalidate specified checkpoint(s).
  lscp     åݥȤȥʥåץåȤ󤹤롣
  mkcp     åݥȤ䥹ʥåץåȤ
  chcp     ¸ΥåݥȤ򥹥ʥåץåȤѴ롣ޤϤ
  	   ε
  rmcp     ꤵ줿åݥȤ̵롣

#To mount a snapshot,
ʥåץåȤޥȤˤϰʲΤ褦ˤޤ

# mount -t nilfs2 -r -o cp=<cno> /dev/block_device /snap_dir

#where <cno> is the checkpoint number of the snapshot.
ǡ<cno> ϥʥåץåȤΥåݥֹǤ

#To unmount the NILFS2 mount point or snapshot, simply:
NILFS2 ޥȥݥȤޤϥʥåץåȤ򥢥ޥȤˤϡñ
˰ʲΤ褦ˤƤ

# umount /dir

#Then, the cleaner daemon is automatically shut down by the umount
#helper program (umount.nilfs2).
θ塢umount إѡץ (umount.nilfs2) ˤꥯ꡼ʥǡ
󤬼ưŪ˥åȥ󤵤ޤ

#Disk format
#===========
ǥեޥå
===================

#A nilfs2 volume is equally divided into a number of segments except
#for the super block (SB) and segment #0.  A segment is the container
#of logs.  Each log is composed of summary information blocks, payload
#blocks, and an optional super root block (SR):
nilfs2 ܥ塼ϥѡ֥å (SB) ȥ #0ʳƱ
쥵ʣȤʬ䤵ƤޤȤϥΥƥ
Ǥƥϥޥ֥åȡڥɥ֥åץΥ
ѡ롼ȥ֥å (SR) 鹽Ƥޤ

#   ______________________________________________________
#  | |SB| | Segment | Segment | Segment | ... | Segment | |
#  |_|__|_|____0____|____1____|____2____|_____|____N____|_|
#  0 +1K +4K       +8M       +16M      +24M  +(8MB x N)
#       .             .            (Typical offsets for 4KB-block)
#    .                  .
#  .______________________.
#  | log | log |... | log |
#  |__1__|__2__|____|__m__|
#        .       .
#      .               .
#    .                       .
#  .______________________________.
#  | Summary | Payload blocks  |SR|
#  |_blocks__|_________________|__|
   ___________________________________________________________
  | |SB| |||| ... || |
  |_|__|_|____0_____|____1__+__|____2_____|_____|____N__+__|_|
  0 +1K +4K        +8M       +16M      +24M   +(8MB x N)
       .             .            (4KB-֥åξ̾Υեå)
    .                  .
  ._______________________
  | | |... | |
  |__1__|__2__|____|__m__|
        .       .
      .               .
    .                       .
  .________________________________.
  |ޥ| ڥ      |SR|
  |_֥å_|__֥å_______|__|

#The payload blocks are organized per file, and each file consists of
#data blocks and B-tree node blocks:
ڥɥ֥åϳƥեбƹƤꡢƥեϥ
֥å B-ĥ꡼Ρɥ֥åǹƤޤ

#    |<---       File-A        --->|<---       File-B        --->|
#   _______________________________________________________________
#    | Data blocks | B-tree blocks | Data blocks | B-tree blocks | ...
#   _|_____________|_______________|_____________|_______________|_
   |<---       ե-A       --->|<---     ե-B       --->|
   _________________________________________________________________
   | ǡ        | B-tree         | ǡ       | B-tree        | ...
   |__֥å_____|___֥å_____|__֥å ___|___֥å____|_


#Since only the modified blocks are written in the log, it may have
#files without data blocks or B-tree node blocks.
ѹ줿֥åΤߤ˽񤫤뤿ᡢǡ֥å B-ĥ꡼
Ρɥ֥åʤե뤬¸ߤ뤫⤷ޤ

#The organization of the blocks is recorded in the summary information
#blocks, which contains a header structure (nilfs_segment_summary), per
#file structures (nilfs_finfo), and per block structures (nilfs_binfo):
֥åιϡޥ֥å˽񤭹ޤޤιˤϡ
å¤ (nilfs_segment_summary)եι¤ (nilfs_finfo) ȥ֥
åι¤ (nilfs_binfo) ޤޤޤ

#  _________________________________________________________________________
# | Summary | finfo | binfo | ... | binfo | finfo | binfo | ... | binfo |...
# |_blocks__|___A___|_(A,1)_|_____|(A,Na)_|___B___|_(B,1)_|_____|(B,Nb)_|___
  _________________________________________________________________________
 |ޥ | finfo | binfo | ... | binfo | finfo | binfo | ... | binfo |...
 |_֥å__|___A___|_(A,1)_|_____|(A,Na)_|___B___|_(B,1)_|_____|(B,Nb)_|___


#The logs include regular files, directory files, symbolic link files
#and several meta data files.  The mata data files are the files used
#to maintain file system meta data.  The current version of NILFS2 uses
#the following meta data files:
ˤϰ̥ե롢ǥ쥯ȥե롢ܥå󥯥ե
ȴ狼Υ᥿ǡե뤬ޤޤޤ᥿ǡեϥե
ƥ᥿ǡݻ뤿ΥեǤߤǤ NILFS2
ǤϰʲΥ᥿ǡեȤäƤޤ

# 1) Inode file (ifile)             -- Stores on-disk inodes
# 2) Checkpoint file (cpfile)       -- Stores checkpoints
# 3) Segment usage file (sufile)    -- Stores allocation state of segments
# 4) Data address translation file  -- Maps virtual block numbers to usual
#    (DAT)                             block numbers.  This file serves to
#                                      make on-disk blocks relocatable.
 1) Inode ե (ifile)          -- ǥ inode Ǽޤ
 2) Checkpoint ե (cpfile)    -- åݥȤǼޤ
 3) Segment usage ե (sufile) -- ȤγƾǼ
 					ޤ
 4) ǡɥ쥹Ѵե      -- ۥ֥åֹ̾Υ֥
 	  (DAT)			       ֹޥåפޤΥե
	   				ϥǥΥ֥å
					ֲǽˤޤ

#The following figure shows a typical organization of the logs:
ʲοޤϡŵŪʹ򼨤ޤ

#  _________________________________________________________________________
# | Summary | regular file | file  | ... | ifile | cpfile | sufile | DAT |SR|
# |_blocks__|_or_directory_|_______|_____|_______|________|________|_____|__|
  _____________________________________________________________________________________
 |ޥ| ̾եޤ | ե  | ... | ifile | cpfile | sufile | DAT |SR|
 |_֥å_|_ǥ쥯ȥ_______|___________|_____|_______|________|________|_____|__|

#To stride over segment boundaries, this sequence of files may be split
#into multiple logs.  The sequence of logs that should be treated as
#logically one log, is delimited with flags marked in the segment
#summary.  The recovery code of nilfs2 looks this boundary information
#to ensure atomicity of updates.
ȶޤˡΥեΥ󥹤ʣΥʬ
ǽǤϢΥŪˤϰĤΥȤư졢
ȥޥǥޡ줿ե饰ʬ䤵ޤnilfs2 ΥꥫХꥳ
Ϥζ򸫤ƹΥȥߥåݾڤޤ

#The super root block is inserted for every checkpoints.  It includes
#three special inodes, inodes for the DAT, cpfile, and sufile.  Inodes
#of regular files, directories, symlinks and other special files, are
#included in the ifile.  The inode of ifile itself is included in the
#corresponding checkpoint entry in the cpfile.  Thus, the hierarchy
#among NILFS2 files can be depicted as follows:
ѡ롼ȥ֥åϥåݥޤϣĤ
ü inode¨ DAT  inodecpfile  sufile ޤߤޤ̾
ǥ쥯ȥꡢܥå󥯤¾Υڥե
 inode  ifile ˳Ǽޤifile Τ inode  cpfile б
åݥȥȥ˳ǼƤޤޤȤȡNILFS2 ե
֤γشطϰʲΤ褦ޤ

#  Super block (SB)
#       |
#       v
#  Super root block (the latest cno=xx)
#       |-- DAT
#       |-- sufile
#       `-- cpfile
#              |-- ifile (cno=c1)
#              |-- ifile (cno=c2) ---- file (ino=i1)
#              :        :          |-- file (ino=i2)
#              `-- ifile (cno=xx)  |-- file (ino=i3)
#                                  :        :
#                                  `-- file (ino=yy)
#                                    ( regular file, directory, or symlink )
  ѡ֥å (SB)
       |
       v
  ѡ롼ȥ֥å (ǿ cno=xx)
       |-- DAT
       |-- sufile
       `-- cpfile
              |-- ifile (cno=c1)
              |-- ifile (cno=c2) ---- ե (ino=i1)
              :        :          |-- ե (ino=i2)
              `-- ifile (cno=xx)  |-- ե (ino=i3)
                                  :        :
                                  `-- ե (ino=yy)
                                    ( ̾Υե롢ǥ쥯ȥꡢ
				    ܥå )

#For detail on the format of each file, please see include/linux/nilfs2_fs.h.
ƥեΥեޥåȤξܺ٤ˤĤƤϡinclude/linux/nilfs2_fs.h 
Ȥ

