作者 | 时间 | QQ技术交流群 |
---|
perrynzhou@gmail.com | 2022/10/01 | 672152841 |

ext4
中inode
数据块存储形式

ext4
目前在kernel
中的实现有两种分别是基于block
和基于extent
。基于block
的方式存储文件数据块的元数据有direct block(直接数据块)
、indirect block(一级间接数据块,pointer to direct blocks)
、double indirect block(二级间接数据块,pointer to indirect blocks)
、triple indirect(三级间接数据块,pointer to double indirect blocks)
.早期是采用这样方式存储,但是有2个弊端其一假设文件是10T文件,基于这样存储形式,整个文件的block元数据是非常多的(由于每个block大小固定);其二如果要读取这个大文件的中一部分数据,查找目标数据块的效率相对比较低。

struct ext4_extent {
__le32 ee_block; /* first logical block extent covers */
__le16 ee_len; /* number of blocks covered by extent */
__le16 ee_start_hi; /* high 16 bits of physical block */
__le32 ee_start_lo; /* low 32 bits of physical block */
};

struct ext4_inode {
__le16 i_mode; /* File mode */
__le16 i_uid; /* Low 16 bits of Owner Uid */
__le32 i_size_lo; /* Size in bytes */
__le32 i_atime; /* Access time */
__le32 i_ctime; /* Inode Change time */
__le32 i_mtime; /* Modification time */
__le32 i_dtime; /* Deletion Time */
// 整个B-Tree的root,EXT4_N_BLOCKS = 15
__le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */
/******忽略*******/
};
ext4
中journal
日志模式

Delayed Allocation
特性