XFS is a high-performance 64-bit journaling file system created by Silicon Graphics for IRIX in 1993 and ported to Linux in the 2000s. It is the default on Red Hat Enterprise Linux and its derivatives and is common on servers, NAS and large-file workloads. It is actively developed in the Linux kernel.
Overview
XFS uses allocation groups, each with its own superblock copy, free space B+-trees and inode B+-tree, which allows parallel operation. Files are mapped by extents; small directories are stored inline in the inode and large ones as B+-trees. Metadata is big-endian. Version 5 adds metadata checksums and a UUID per structure.
History
Developed by SGI for IRIX (released 1994).
Ported to Linux in 2001 and merged into Linux 2.5.36.
The v5 on-disk format with checksums was introduced in Linux 3.10 (2013).
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.
Extents
Offset
Size
Type
Field
Notes
0x0
2
u16 BE
Level
0x2
2
u16 BE
Records
4 + maxRecords * 8 + i * 8
8
u64 BE
Child
Parse Data Block
Offset
Size
Type
Field
Notes
0x0
4
u32 BE
Agic
position
2
u16 BE
–
position
8
u64 BE
Number
position + 2
2
u16 BE
Free
block.Length – 8
4
u32 BE
Leaf Count
position + 8
1
u8
Name Length
Read Bmap Block
Offset
Size
Type
Field
Notes
0x0
4
u32 BE
Agic
0x4
2
u16 BE
Level
0x6
2
u16 BE
Records
header + maxRecords * 8 + i * 8
8
u64 BE
Child
Read Shortform Directory
Offset
Size
Type
Field
Notes
0x0
1
u8
Count
0x1
1
u8
Wide
0x1
1
u8
Total
inodeStart
8
u64 BE
Number
inodeStart
4
u32 BE
Number
Read Symlink
Offset
Size
Type
Field
Notes
0x0
4
u32 BE
–
0x8
4
u32 BE
Bytes
Parse
Offset
Size
Type
Field
Notes
0x0
2
u16 BE
–
0x2
2
u16 BE
Mode
0x4
1
u8
Version
0x5
1
u8
Format
0x6
2
u16 BE
–
0x8
4
u32 BE
Uid
0xC
4
u32 BE
Gid
0x10
4
u32 BE
–
0x38
8
u64 BE
Size
0x40
8
u64 BE
Blocks
0x4C
4
u32 BE
Extent Count
0x52
1
u8
Fork Offset
0x5A
2
u16 BE
Flags
0x78
8
u64 BE
–
Time
Offset
Size
Type
Field
Notes
offset
8
u64 BE
Value
offset + 4
4
u32 BE
Nanoseconds
Try Parse
Offset
Size
Type
Field
Notes
0x0
4
u32 BE
–
0x4
4
u32 BE
Block Size
0x8
8
u64 BE
Data Blocks
0x38
8
u64 BE
Root Inode
0x54
4
u32 BE
Ag Blocks
0x58
4
u32 BE
Ag Count
0x64
2
u16 BE
Version
0x66
2
u16 BE
Sector Size
0x68
2
u16 BE
Inode Size
0x78
1
u8
Block Log
0x7A
1
u8
Inode Log
0x7B
1
u8
Inodes Per Block Log
0x7C
1
u8
Ag Block Log
0x7E
1
u8
In Progress
0x80
8
u64 BE
Inode Count
0x88
8
u64 BE
Free Inodes
0x90
8
u64 BE
Free Data Blocks
0xC0
1
u8
Dir Block Log
0xC0
1
u8
–
0xC8
4
u32 BE
Features2
0xD8
4
u32 BE
–
Decode
Offset
Size
Type
Field
Notes
0x0
8
u64 BE
L0
0x8
8
u64 BE
L1
Other fields read
Read in
Offset
Size
Type
Field
Notes
Has Inode At
0x0
2
u16 BE
–
Constants
Directory data block magics
Name
Value
Type
Notes
DirBlockV4
0x58443242
uint
XD2B
DirDataV4
0x58443244
uint
XD2D
DirBlockV5
0x58444233
uint
XDB3
DirDataV5
0x58444433
uint
XDD3
BmapV4
0x424D4150
uint
BMAP
BmapV5
0x424D4133
uint
BMA3
SymlinkV5
0x58534C4D
uint
XSLM
DirLeafOffset
32L * 1024 * 1024 * 1024
long
Xfs Superblock
Name
Value
Type
Notes
Magic
0x58465342
uint
“XFSB”
sb_features_incompat (v5) / sb_features2 (v4)
Name
Value
Type
Notes
IncompatFtype
0x1
uint
IncompatBigTime
0x8
uint
Features2Ftype
0x200
uint
Xfs Inode
Name
Value
Type
Notes
Magic
0x494E
ushort
“IN”
FormatDevice
0
byte
FormatLocal
1
byte
FormatExtents
2
byte
FormatBtree
3
byte
FlagRealtime
0x0001
ushort
FlagImmutable
0x0008
ushort
FlagAppend
0x0010
ushort
Flag2BigTime
0x0008
ulong
Implementation limits
Class
Name
Value
Notes
Xfs File System
MaxBtreeDepth
10
Xfs File System
MaxExtents
4_000_000
Xfs File System
MaxDirectoryBytes
512L * 1024 * 1024
Xfs File System
MaxSymlinkLength
4096
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.