linux/Documentation/filesystems/nilfs2.txt
<<
>>
Prefs
   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/
  31List info:           http://vger.kernel.org/vger-lists.html#linux-nilfs
  32
  33Caveats
  34=======
  35
  36Features which NILFS2 does not support yet:
  37
  38        - atime
  39        - extended attributes
  40        - POSIX ACLs
  41        - quotas
  42        - fsck
  43        - defragmentation
  44
  45Mount options
  46=============
  47
  48NILFS2 supports the following mount options:
  49(*) == default
  50
  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.
  55errors=continue         Keep going on a filesystem error.
  56errors=remount-ro(*)    Remount the filesystem read-only on an error.
  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.
  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.
  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.
  83
  84NILFS2 usage
  85============
  86
  87To use nilfs2 as a local file system, simply:
  88
  89 # mkfs -t nilfs2 /dev/block_device
  90 # mount -t nilfs2 /dev/block_device /dir
  91
  92This will also invoke the cleaner through the mount helper program
  93(mount.nilfs2).
  94
  95Checkpoints and snapshots are managed by the following commands.
  96Their manpages are included in the nilfs-utils package above.
  97
  98  lscp     list checkpoints or snapshots.
  99  mkcp     make a checkpoint or a snapshot.
 100  chcp     change an existing checkpoint to a snapshot or vice versa.
 101  rmcp     invalidate specified checkpoint(s).
 102
 103To mount a snapshot,
 104
 105 # mount -t nilfs2 -r -o cp=<cno> /dev/block_device /snap_dir
 106
 107where <cno> is the checkpoint number of the snapshot.
 108
 109To unmount the NILFS2 mount point or snapshot, simply:
 110
 111 # umount /dir
 112
 113Then, the cleaner daemon is automatically shut down by the umount
 114helper program (umount.nilfs2).
 115
 116Disk format
 117===========
 118
 119A nilfs2 volume is equally divided into a number of segments except
 120for the super block (SB) and segment #0.  A segment is the container
 121of logs.  Each log is composed of summary information blocks, payload
 122blocks, and an optional super root block (SR):
 123
 124   ______________________________________________________
 125  | |SB| | Segment | Segment | Segment | ... | Segment | |
 126  |_|__|_|____0____|____1____|____2____|_____|____N____|_|
 127  0 +1K +4K       +8M       +16M      +24M  +(8MB x N)
 128       .             .            (Typical offsets for 4KB-block)
 129    .                  .
 130  .______________________.
 131  | log | log |... | log |
 132  |__1__|__2__|____|__m__|
 133        .       .
 134      .               .
 135    .                       .
 136  .______________________________.
 137  | Summary | Payload blocks  |SR|
 138  |_blocks__|_________________|__|
 139
 140The payload blocks are organized per file, and each file consists of
 141data blocks and B-tree node blocks:
 142
 143    |<---       File-A        --->|<---       File-B        --->|
 144   _______________________________________________________________
 145    |s="line" name="Lscp     list checkpoints or snapsho61"> 134    |s="lir througutG1/file14stems/ni38" id="L138" c8" id="L138" cla8" id="L138" c8" id="L138" cla8"e" name="Lscp     list checkpoints or snapsho61"> _______.
=
  47
   lfs2.txt#L1428">  50
 121"L107">txt#L14     came=class="line" name="L121"> 12/nilfs2.txt#L91" id="L91" class="line" name="L911e 142
d
  r the " id="aj="L7" id="L4 (e" na_L120"> _ne" nam),ILFS2 creates a number of checkpoints every few secone, it wil1l
 141data blocks and B-tree noda warning1.
 144   _____a>   ______________________________________________________ an error1.
or occurs1.
o options1e
  7ilfsEach log is composed of summary information blocks together1.
 141data blocks and B-tree nodt making 1a
  6i" cltlfs2.txt#L110" id="L110" class="line" name="L110"san error13
 125<.txt#aclass(suclasxt#L543"S cla" rderc"> 121Docue"> 119A lfs2.txt#L110" id="L110" class="line" name="L110"s options1s
 121class543"Maps virtuala id="L="L119ss="lusuallfs2.txt#L110" id="L110" class="line" name="L110"erwriting1.
  6txt#L14reerc">ame=ne" name="Lscp     list checkpoints or snapsho61">ng of dat1a
 121"L107">31" ne" name="L141"> 141data blocks and B-tree nodvered fil1e
 144   _____a>   ______________________________________________________ on mount1.
 137  | Summary | Payload blo7>  16

="L126">="LL126">="LL126">=="line" name="L138"> 138  |_blocks__|____________ will fai1l
  7imay >    li volume is equally divided into a number of segmenunderlyin1g
  tme="L131" id="L41" class="line" name="L41">  41      1 is usefu1l
  41      1 d that n1.
 12/nilfs2.txt#L91" id="L91" class="line" name="L911">  83
LFS2 usag1e
  41      1 >  16>
"AT,"cpclase="L14suclasl  I" cltlfs2.txt#L110" id="L110" class="line" name="L110"m, simply1:
  88
  7i 52 141data blocks and B-tree nod">  91
  83 138  |_blocks__|____________">  94
 138  |_blocks__|____________"========1.
37  16.

 a>      L121">ine" "> 140  lin0id="L96"  
  74                        system afte2> 1082
/nil" igi#L8" XR softwL14013T74">  74 XR /a>Cunnams/nixt="L61ex120i     l#L13" id113<74">  74 to:lxr@
lxr@

lxr.
  74Redpill L 1LTheulti    " io" name="L7=trine" nsne" n19s5.