首页 > 其他分享 >ext4 extent 寻址方案

ext4 extent 寻址方案

时间:2023-06-01 10:32:52浏览次数:33  
标签:__ node ext4 tree 寻址 extent block


Extent Tree

In ext4, the file to logical block map has been replaced with an extent tree. Under the old scheme, allocating a contiguous run of 1,000 blocks requires an indirect block to map all 1,000 entries; with extents, the mapping is reduced to a single struct ext4_extent with ee_len = 1000. If flex_bg is enabled, it is possible to allocate very large files with a single extent, at a considerable reduction in metadata block use, and some improvement in disk efficiency. The inode must have the extents flag (0x80000) flag set for this feature to be in use.

Extents are arranged as a tree. Each node of the tree begins with a struct ext4_extent_header. If the node is an interior node (eh.eh_depth > 0), the header is followed by eh.eh_entries instances of struct ext4_extent_idx; each of these index entries points to a block containing more nodes in the extent tree. If the node is a leaf node (eh.eh_depth == 0), then the header is followed by eh.eh_entries instances of struct ext4_extent; these instances point to the file's data blocks. The root node of the extent tree is stored in inode.i_block, which allows for the first four extents to be recorded without the use of extra metadata blocks.

The extent tree header is recorded in struct ext4_extent_header, which is 12 bytes long:

Offset

Size

Name

Description

0x0

__le16

eh_magic

Magic

number, 0xF30A.

0x2

__le16

eh_entries

Number of valid entries following the header.

0x4

__le16

eh_max

Maximum number of entries that could follow the header.

0x6

__le16

eh_depth

Depth

of this extent node in the extent tree. 0 = this extent node points to data blocks; otherwise, this extent node points to other extent nodes. The extent tree can be at most 5 levels deep: a logical block number can be at most 2^32, and the smallest n

that satisfies 4*(((blocksize - 12)/12)^n) >= 2^32 is 5.

0x8

__le32

eh_generation

Generation of the tree. (Used by Lustre, but not standard ext4).

Internal nodes of the extent tree, also known as index nodes, are recorded as struct ext4_extent_idx, and are 12 bytes long:

Offset

Size

Name

Description

0x0

__le32

ei_block

This

index node covers file blocks from 'block' onward.

0x4

__le32

ei_leaf_lo

Lower 32-bits of the block number of the extent node that is the next level lower in the tree. The tree node pointed to can be either another

internal node or a leaf node, described below.

0x8

__le16

ei_leaf_hi

Upper 16-bits of the previous field.

0xA

__u16

ei_unused

 

Leaf nodes of the extent tree are recorded as struct ext4_extent, and are also 12 bytes long:

Offset

Size

Name

Description

0x0

__le32

ee_block

First

file block number that this extent covers.

0x4

__le16

ee_len

Number of blocks covered by extent. If the value of this field is <= 32768, the extent is initialized. If the value of the field is > 32768, the extent is

uninitialized and the actual extent length is ee_len - 32768. Therefore, the maximum length of a initialized extent is 32768 blocks, and the maximum length of an uninitialized extent is 32767.

0x6

__le16

ee_start_hi

Upper

16-bits of the block number to which this extent points.

0x8

__le32

ee_start_lo

Lower 32-bits of the block number to which this extent points.

Prior to the introduction of metadata checksums, the extent header + extent entries always left at least 4 bytes of unallocated space at the end of each extent tree data block (because (2^x % 12) >= 4). Therefore, the 32-bit checksum is inserted into this space. The 4 extents in the inode do not need checksumming, since the inode is already checksummed. The checksum is calculated against the FS UUID, the inode number, the inode generation, and the entire extent block leading up to (but not including) the checksum itself.

struct ext4_extent_tail is 4 bytes long:

Offset

Size

Name

Description

0x0

__le32

eb_checksum

Checksum

of the extent block, crc32c(uuid+inum+igeneration+extentblock)

标签:__,node,ext4,tree,寻址,extent,block
From: https://blog.51cto.com/u_11860992/6392725

相关文章

  • linux 一块空磁盘初始化为dos的磁盘分区表,然后可以直接初始化整个磁盘为ext4格式,也可
    问:linux一块空磁盘初始化为dos的磁盘分区表,然后可以直接初始化整个磁盘为ext4格式,也可以先把磁盘分出一个Partition再初始化为ext4格式,这两种方式有什么区别,有什么特点答:在Linux上,对一块空磁盘进行初始化为ext4文件系统时,你可以选择两种不同的方式:直接初始化整个磁盘为......
  • 寄存器寻址和寄存器间接寻址的区别
    寄存器寻址(RegisterDirectAddressing)和寄存器间接寻址(RegisterIndirectAddressing)是计算机体系结构中两种不同的寻址模式。它们用于确定指令中操作数所在的位置或获取操作数的值。下面将详细介绍寄存器寻址和寄存器间接寻址的区别以及它们的应用。寄存器寻址:寄存器寻址是......
  • 哈希表处理冲突的开放寻址法
    /**链结点,相当于是车厢*/publicclassNode{ //数据域 publicInfoinfo; //指针域 publicNodenext; publicNode(Infoinfo){ this.info=info; } } /**链表,相当于火车*/publicclassLinkList{ //头结点 privateNodefirst; public......
  • 汇编_寻址方式在结构化数据访问中的应用
    如何寻址数据巩固一下寄存器reg:ax,bx,cx,dx,ap,bp,si,disreg:ds,ss,cs,esbx,si,di,bp在8086CPU中,只有这4个寄存器可以用在"[...]"中进行内存单元的寻址。这4个寄存器可以单个出现,或只能以4种组合出现:bx和si、bx和di、bp和si、bp和di。只要在[...]中使用......
  • RK3588 Android12 编译打包私有ext4格式vendor.img并挂载到新增vendor_private分区
    一、制作ext4格式的vendor.img使用simg2img工具直接将现有的vendor.img转换成ext4格式的vendor.disk即可 ./out/host/linux-x86/bin/simg2img  out/target/product/ribeye/vendor.img  vendor.disk然后就可以直接挂载到新增分区对应的目录:mount vendor.disk/vendor_......
  • dba_segments与dba_extents
    好久没写博客了最近在忙的有几点1.RAC+ADG基于阿里云DBFS数据库文件系统,实验训练一周被告知项目内容可能会更改,只剩下ADG容灾。2.挖矿病毒提前防护,客户中毒较多,打了一片片的补丁。3.RAC集群宕机,原因查了两天,发现服务器本身问题,有点无语。4.拆分数据库内容优化及处理,之前没怎......
  • 我要提取text4文本中的邮箱号 正则应该怎么写?
    大家好,我是皮皮。一、前言前几天在Python白银交流群【膨胀西瓜汁】问了一个Python正则表达式的问题,这里拿出来给大家分享下。代码如下:二、实现过程这里【甯同学】给了一个思路,如下图所示:直接使用字符串+列表推导式搞定了,太强了!不过粉丝正好在学习正则表达式,所以还是希望......
  • # yyds干货盘点 # 我要提取text4文本中的邮箱号 正则应该怎么写?
    大家好,我是皮皮。一、前言前几天在Python白银交流群【膨胀西瓜汁】问了一个Python正则表达式的问题,这里拿出来给大家分享下。代码如下:二、实现过程这里【甯同学】给了一个思路,如下图所示:直接使用字符串+列表推导式搞定了,太强了!不过粉丝正好在学习正则表达式,所以还是希望能够用正则......
  • make_ext4fs error: make_file: failed to allocate inode
    make_ext4fserror:make_file:failedtoallocateinodeerror:do_inode_allocate_extents:Failedtoallocate1146blocksmakemenuconfigTargetImages--->[*]ext4--->(60000)Maximumnumberofinodesinrootfilesystem无脑6000改为60000同样的还有改sys......
  • Sublime Text4 如何修改主题,如何修改配色方案
    第一步,打开SublimeText4,在顶部的菜单找到:Preferences,点击并在下拉菜单选择SelectColorScheme,在弹出的窗口,点击Monokai,这样配色方案就切换为旧版本的样式了。......