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

OffsetSizeTypeFieldNotes
p8u64 LEChild
p + 82u16 LERecord Length
p + 101u8Name Length

Make Entry

OffsetSizeTypeFieldNotes
0x88u64 LESize
0x284u32 LE–
0x2C4u32 LE–
0x302u16 LEOde

Nilfs2 File System

OffsetSizeTypeFieldNotes
0x208u64 LETotal Bytes
0x508u64 LEFree Bytes

Checkpoint

OffsetSizeTypeFieldNotes
0x04u32 LEFlags
0x188u64 LE–0x02: invalid

Find Super Root

OffsetSizeTypeFieldNotes
0x304u32 LEPer Segment
0x408u64 LEPseg

Find Super Root

OffsetSizeTypeFieldNotes
0x84u32 LE–
0x108u64 LE–

Find Super Root

OffsetSizeTypeFieldNotes
0x84u32 LE–
0xE2u16 LEFlags
0x108u64 LESeq
0x208u64 LENextss_next: the next segment’s start
0x284u32 LEBlocks
0x388u64 LEBest Cno

Latest Checkpoint

OffsetSizeTypeFieldNotes
0x388u64 LEFloor
0x388u64 LECno

Map

OffsetSizeTypeFieldNotes
0x11u8Level
0x22u16 LECount

Map

OffsetSizeTypeFieldNotes
BmapAt + 11u8Level
BmapAt + 22u16 LECount
BmapAt + 8 + (int)key * 88u64 LE–

Map

OffsetSizeTypeFieldNotes
keysAt + i * 88u64 LE–
keysAt + index * 88u64 LE–
ptrsAt + index * 88u64 LEPointer

Nilfs2 Volume

OffsetSizeTypeFieldNotes
0x144u32 LEBlock Size
0x902u16 LEInode Size
0x922u16 LEDat Entry Size
0x942u16 LECheckpoint Size

Read Superblock

OffsetSizeTypeFieldNotes
0x62u16 LE–
0x144u32 LELog
0x304u32 LEPer Segment

Snapshots

OffsetSizeTypeFieldNotes
0x04u32 LE–
0x88u64 LENext

Other fields read

Read inOffsetSizeTypeFieldNotes
Read All0x88u64 LESize
Runs0x88u64 LESize
Timeat8u64 LESeconds
Probe0x208u64 LEVolume Length
Details0x304u32 LE–
Snapshots0x108u64 LENext
Translateoffset8u64 LE–

Constants

Nilfs2 Volume

NameValueTypeNotes
SummaryMagic0x1EAFFA11uint
BmapAt56int
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.