NILFS2 (New Implementation of a Log-structured File System)
NILFS2 is a log-structured Linux file system from NTT (Linux 2.6.30, 2009) that takes continuous checkpoints and can snapshot any of them. It has limited adoption and is maintained in the kernel.
Overview
NILFS2 never overwrites data. The disk is a sequence of segments, each holding partial segments of file data, B-tree nodes and a summary. Checkpoints are created continuously and can be turned into snapshots. Inodes, checkpoints and segment usage live in metadata files. Two superblocks at the start and end of the volume point to the newest segment.
History
Developed by NTT Labs; merged into Linux 2.6.30 (2009).
Structures
Offsets are in bytes from the start of the structure named in each heading. Field names are descriptive and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.
Get Children
Offset
Size
Type
Field
Notes
p
8
u64 LE
Child
p + 8
2
u16 LE
Record Length
p + 10
1
u8
Name Length
Make Entry
Offset
Size
Type
Field
Notes
0x8
8
u64 LE
Size
0x28
4
u32 LE
–
0x2C
4
u32 LE
–
0x30
2
u16 LE
Ode
Nilfs2 File System
Offset
Size
Type
Field
Notes
0x20
8
u64 LE
Total Bytes
0x50
8
u64 LE
Free Bytes
Checkpoint
Offset
Size
Type
Field
Notes
0x0
4
u32 LE
Flags
0x18
8
u64 LE
–
0x02: invalid
Find Super Root
Offset
Size
Type
Field
Notes
0x30
4
u32 LE
Per Segment
0x40
8
u64 LE
Pseg
Find Super Root
Offset
Size
Type
Field
Notes
0x8
4
u32 LE
–
0x10
8
u64 LE
–
Find Super Root
Offset
Size
Type
Field
Notes
0x8
4
u32 LE
–
0xE
2
u16 LE
Flags
0x10
8
u64 LE
Seq
0x20
8
u64 LE
Next
ss_next: the next segment’s start
0x28
4
u32 LE
Blocks
0x38
8
u64 LE
Best Cno
Latest Checkpoint
Offset
Size
Type
Field
Notes
0x38
8
u64 LE
Floor
0x38
8
u64 LE
Cno
Map
Offset
Size
Type
Field
Notes
0x1
1
u8
Level
0x2
2
u16 LE
Count
Map
Offset
Size
Type
Field
Notes
BmapAt + 1
1
u8
Level
BmapAt + 2
2
u16 LE
Count
BmapAt + 8 + (int)key * 8
8
u64 LE
–
Map
Offset
Size
Type
Field
Notes
keysAt + i * 8
8
u64 LE
–
keysAt + index * 8
8
u64 LE
–
ptrsAt + index * 8
8
u64 LE
Pointer
Nilfs2 Volume
Offset
Size
Type
Field
Notes
0x14
4
u32 LE
Block Size
0x90
2
u16 LE
Inode Size
0x92
2
u16 LE
Dat Entry Size
0x94
2
u16 LE
Checkpoint Size
Read Superblock
Offset
Size
Type
Field
Notes
0x6
2
u16 LE
–
0x14
4
u32 LE
Log
0x30
4
u32 LE
Per Segment
Snapshots
Offset
Size
Type
Field
Notes
0x0
4
u32 LE
–
0x8
8
u64 LE
Next
Other fields read
Read in
Offset
Size
Type
Field
Notes
Read All
0x8
8
u64 LE
Size
Runs
0x8
8
u64 LE
Size
Time
at
8
u64 LE
Seconds
Probe
0x20
8
u64 LE
Volume Length
Details
0x30
4
u32 LE
–
Snapshots
0x10
8
u64 LE
Next
Translate
offset
8
u64 LE
–
Constants
Nilfs2 Volume
Name
Value
Type
Notes
SummaryMagic
0x1EAFFA11
uint
BmapAt
56
int
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.