xfs

Terminology

Common Types

type name representation
xfs_ino_t unsigned 64 bit absolute inode number
xfs_off_t signed 64 bit file offset
xfs_daddr_t signed 64 bit disk address
xfs_agnubmer_t unsigned 32 bit AG number
xfs_agblock_t unsigned 32 bit AG relative block number
xfs_extlen_t unsigned 32 bit extent length in blocks
xfs_extnum_t signed 32 bit number of extent in a file
xfs_dablk_t unsigned 32 bit block number of directories and extended attributes
xfs_dahash_t unsigned 32 bit hash of a directory file name or extended attribute name
xfs_dfsbno_t unsigned 64 bit filesystem block number combining AG number and block offset into the AG
xfs_drfsbno_t unsigned 64 bit raw filesystem block number
xfs_drtbno_t unsigned 64 bit extent number in the real-time sub-volume
xfs_dfiloff_t unsigned 64 bit block offset into a file
xfs_dfilblks_t unsigned 64 bit block count for a file

Allocation Group

XFS filesystems are divided into a number of equally sized chunks called Allocation Groups. Each AG can almost be thought of as an individual filesystem that maintains it’s own space usage. Each AG can be up to one terabyte in size (512 bytes * 2^31 ), regardless of the underlying device’s sector size.

The first AG is the primary AG, and it maintains the global information, i.e. , free space across the filesystem and total inode counts.

AG Layout:

field size usage
Superblock(SB) 1 sector superblock of all the filesystem, only the SB of the primary AG is valid
AG free block info(AGF) 1 sector root pointers of two B+ tree for free spaces for data and metadata of the filesystem
AG inode B+ tree info 1 sector
AG internal free list(AGFL) 1 sector a list of block pointers for reserved space for growing AGF B+ trees(not general data of the FS)
Root of inode B+tree 1 block
Root of free space B+tree(key = block number) 1 block
Root of free space B+tree(key = block count) 1 block

Superblocks

Each AG starts with a superblock, the first one is the primary superblock that stores aggregate AG information. Secondary ones are used by xfs_repair when the primary one has been corrupted.

AG Free Space Management

XFS tracks free space in an allocation group using two B+ trees: + tracking space by block number + tracking space by size

All block numbers, indexes and counts are AG relative.

B+ tree Node layout |type|number|meaning| |—-|——|——-| |xfs_btree_sblock|1|header of node| |xfs_alloc_key_t|xfs_btree_sblock->bb_numrecs|key in btree| |xfs_alloc_ptr_t|xfs_btree_sblock->bb_numrecs|block number of child|

B+ tree Leaf layout |type|number|meaning| |—-|——|——-| |xfs_btree_sblock|1|header of node| |xfs_alloc_rec_t|xfs_btree_sblock->bb_numrecs|(start block, block count) tuple|

AG Free List

an array of AG relative block pointers for reserved space for growing the free space B+trees. This space cannot be used for general user data including inodes, data, directories and extended attributes.

comments powered by Disqus