XFS file system
Super block:
The hyper block records some important data from the entire XFS file system, such as the total number of disk blocks (usually in 4096 bytes), the size of the disk block, the number of disk blocks used, and the like. Super block is the most important part of the entire file system. If his data is incorrect, the file system cannot be used, so each assignment group has a super block, but only the first assigned group of super blocks, other It is backup. In this way, if the super block is damaged, other assignment groups can be used, some data may be lost, but the entire file system cannot be used.
The structure on the disk of the super block is exactly the same in the XFS_SB structure in the Linux source code.
Typedef struct XFS_SB
{
__UINT32_T SB_MAGICNUM;
4 bytes of file system indicates, translated into Chinese, called the magic number!
For the XFS file system, he is four letters "XFSB"
__UINT32_T SB_BLOCKSIZE;
The number of bytes accounted for a disk block (usually 4096 bytes)
XFS_DRFSBNO_T SB_DBLOCKS;
Data block
XFS_DRFSBNO_T SB_RBLOCKS;
Number of real-time data blocks
XFS_DRTBNO_T SB_REXTENTS;
Number of real-time regions
UUID_T SB_UUID;
File system UUID
XFS_DFSBNO_T SB_LOGSTART;
Start block of the log area
XFS_INO_T SB_ROOTINO;
Root node index node ID
XFS_INO_T SB_RBMINO;
XFS_INO_T SB_RSUMINO;
XFS_AGBLOCK_T SB_REXTSIZE;
XFS_AGBLOCK_T SB_AGBLOCKS;
A number of blocks of a distribution group
XFS_AGNUMBER_T SB_AGCOUNT;
Number of assigned groups
XFS_EXTLEN_T SB_RBMBLOCKS;
XFS_EXTLEN_T SB_LOGBLOCKS;
Number of log blocks
__UINT16_T SB_VERSIONNUM;
__UINT16_T SB_SECTSIZE;
__UINT16_T SB_INODESIZE;
Number of bytes occupying a index node
__UINT16_T SB_INOPBLOCK;
How many index nodes have a disk block?
Char SB_FNAME [12];
Name of the file system
__UINT8_T SB_BLOCKLOG;
__UINT8_T SB_SECTLOG;
__UINT8_T SB_INODELOG;
__UINT8_T SB_INOPBLOG;
__UINT8_T SB_AGBLKLOG;
__UINT8_T SB_REXTSLOG;
__UINT8_T SB_INPROGRESS;
__UINT8_T SB_IMAX_PCT;
__UINT64_T SB_ICOUNT;
Number of allocated index nodes
__UINT64_T SB_IFREE;
The number of remaining index nodes
__UINT64_T SB_FDBLOCKS;
Idle data block
__UINT64_T SB_FREXTENTS; XFS_INO_T SB_UQUOTINO;
ID of index node for managing user quotas
XFS_INO_T SB_GQUOTINO;
ID of the index node used to manage group quotas
__UINT16_T SB_QFLAGS;
__UINT8_T SB_FLAGS;
__UINT8_T SB_SHARED_VN;
XFS_EXTLEN_T SB_INOALIGNMT;
__UINT32_T SB_UNIT;
__UINT32_T SB_WIDTH;
__UINT8_T SB_DIRBLKLOG;
__UINT8_T SB_LOGSECTLOG;
__UINT16_T SB_LOGSECTSIZE;
__UINT32_T SB_LOGSUNIT;
} XFS_SB_T;
The first index node of the file system ---- The index node ID = 128 of the root directory is to the smallest index node, which is located at the 64th block (512 byte) position. The user quota file is 132, and the group quota file is 133. For NEC's SXFS file system: The index node of the SNAP file is 131, the DataSet file is 135.
The file system is just made, that is, when it is formatted, a part of the index node is pre-allocated. For each assignment group, the IDs of these index nodes are 128-191. The index node accounts for 256 bytes, and each two nodes account for a 512-byte block. Index these nodes are continuously distributed between the 64th-96 blocks. Although index node structural XFS_Dinode_core is only 128 bytes, but an index node accounts for 256 bytes of disk space. why? Mainly in order to store data relatively small nodes, for example, there may be three files below, and the three Entry of these three files can be stored in a 128-byte space, so they don't have to give this directory. The node allocates the data block, and stores three files Entry can be stored in the 256-byte area of the directory node.
Why is the ID of the index node starting from 128?
An assignment group consists of a series of 512 bytes of blocks. The first 63 blocks are used to store information or assignment groups. Each 2 index nodes account for 512 bytes, if calculated from the 0th block, the 64th block is exactly the position of 128, 129. This way if you find a node by ID, you can find a location with 2, you can find a location. For example, 128/2 = 64, the index node of the ID 128 is in the 64th block. In addition, if the pre-allocated node is used up, the system will open a space to continue allocation, but the node number will not start from the previous start, because the node number is related to the block number of the block. For example, the pre-allocated node is 12-191, if used, the system is allocated by the ID is not necessarily 192, which is to see if the 96th block is used, in fact, the 96th block is the data block of the quota file. If the node is on the 200th block, his ID is 200 * 2 = 400.
The structure of the XAGF block and the XFS_AGF structure in the source code are the same.
The structure of the XAGI block and the XFS_AGI structure in the source code are the same.
Inode structure
The inode structure present in the disk and the XFS_DINODE structure in the source code are the same. Inside the file size, the number of pieces, the number of ID, time, etc. of the parent directory node. But there is no information for node name, because the name exists in the parent directory.
How is the extra 128-byte processed?
Typedef struct xfs_dinode
{
XFS_DINODE_CORE_T DI_CORE;
XFS_AGINO_T DI_NEXT_UNLINKED; / * AGI UNLINKED LIST PTR * /
Union {
XFS_BMDR_BLOCK_T DI_BMBT; / * BTREE ROOT BLOCK * /
XFS_BMBT_REC_32_T DI_BMX [1]; / * EXTENT LIST * /
XFS_DIR_SHORTFORM_T DI_DIRSF; / * ShortForm Directory * /
XFS_DIR2_SF_T DI_DIR2SF; / * ShortForm Directory V2 * /
Char di_c [1]; / * local contents * /
XFS_DEV_T DI_DEV; / * DEVICE for S_IFCHR / S_IFBLK * /
UUID_T DI_MUUID; / * MOUNT POINT VALUE * /
Char di_symlink [1]; / * local symbolic link * /
} DI_U;
Union {
XFS_BMDR_BLOCK_T DI_ABMBT; / * BTREE ROOT BLOCK * /
XFS_BMBT_REC_32_T DI_ABMX [1]; / * EXTENT LIST * /
XFS_ATTR_SHORTFORM_T DI_ATTRSF; / * ShortForm Attribute List * /
} DI_A;
} XFS_DINODE_T;
If the child node is too much, the excess 128 bytes are already installed, then DI_U will be di_bmbt role.
User quota node
This node number is 132, located in the 66th block, found the 96th block for his data block according to the DI_U field. This block is composed of Entry, and the first two bytes of each entry is "DQ" indicates quota data. The structure of the Entry is the same as the XFS_Disk_dquot structure. Contains quota type, soft and hard limit, number of nodes and numbers used.
Group quota node
This node number: 133, located in the second half of the 66th block, found the 104th block for his data block according to the DI_U field. The fast structure is also composed of Entry, and the same is the same as User Quota.
NEC's DataSet node
DataSet Node Number: 135, located in the second half of the 67th block, found the 112 block for his data block according to the DI_U field. This block is also composed of Entry, and each of his Entry heads is "DD", indicating the block of the data set. The ENTRY structure is the same as the SXFS_DASET_DISK structure.
Endian format
The format on the memory and disk is the opposite when the variable is stored in the endon format.
For example, int I = 0x12345678; // In memory 0x12345678
i will be 0x87654321 on disk
So many XFS_INO_T INODE = 0x80; on disk is 0x80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00