8
26
2014
0

ext4文件系统浅析----跨度之大的inode号

最近在研究ext4文件系统,系统同道之人能共同研究、探讨

 

背景:

在根目录底下

root@f303server:/mnt/sde3# ls -i

     14 2.txt   786433 dir1  1048577 dir3        1179649 mkfs

     15 3.txt   917505 dir2       11 lost+found       13 sde3.txt

 

问题:

用黄色标记的几个为目录项,其中lost+found是格式化、挂载文件系统时自带的目录,其余四个是我创建的。那么问题来了,为什么我创建目录结点的inode号那么的大?

 

 

解释:

在ext4中,文件系统为了保证数据能更加均匀地分布在磁盘上,所以在创建目录时,尽量均匀地分布在不同的flexible block_group(flexbg)中。且同一个目录下的文件和这个目录的inode号在一个flexbg中:

 

默认一个flexbg含有16个block group,故 一个flexbg中含有inode结点数为8196 * 16 = 131072 个。所以dir1786433 位于第6flexbg中(131072 * 6 + 1 = 786433,在dir1目录下的1.txt,查看其inode结点号为  786434

 

同理可以计算其他的三个目录分别在第789flexbg

 

 

 

ps:

1怎么查看一个group有多少个inode结点:

debugfs /dev/sde3

stats

显示如下

 

debugfs

Stats
Filesystem volume name:   <none>
Last mounted on:          /mnt/sde3
Filesystem UUID:          fea02b9a-41d1-4bf1-96ce-d3298d67778f
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              1310720
Block count:              5242880
Reserved block count:     262144
Free blocks:              5116587
Free inodes:              1310705
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      1022
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512  #Inode table所占的块数目
Flex block group size:    16         #下面前16个inode bitmap所在
Filesystem created:       Mon Jul 28 08:40:58 2014
Last mount time:          Tue Jul 29 19:53:03 2014
Last write time:          Tue Jul 29 19:53:03 2014
Mount count:              8
Maximum mount count:      -1
Last checked:             Mon Jul 28 08:40:58 2014
Check interval:           0 (<none>)
Lifetime writes:          454 MB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               256
Required extra isize:     28
Desired extra isize:      28
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      0da457a4-59ff-402a-9181-c66156ea5991
Journal backup:           inode blocks
Directories:              6
Group  0: block bitmap at 1025, inode bitmap at 1041, inode table at 1057
           23513 free blocks, 8178 free inodes, 2 used directories, 8176 unused inodes
           [Checksum 0x7a6d]
 Group  1: block bitmap at 1026, inode bitmap at 1042, inode table at 1569
           31740 free blocks, 8192 free inodes, 0 used directories, 8192 unused inodes
           [Inode not init, Checksum 0x2c05]
 Group  2: block bitmap at 1027, inode bitmap at 1043, inode table at 2081
           32768 free blocks, 8192 free inodes, 0 used directories, 8192 unused inodes
           [Inode not init, Block not init, Checksum 0x7c29]
 Group  3: block bitmap at 1028, inode bitmap at 1044, inode table at 2593
           31743 free blocks, 8192 free inodes, 0 used directories, 8192 unused inodes
           [Inode not init, Checksum 0x1e2b]延迟初始化
………..
……..
Group 12: block bitmap at 1037, inode bitmap at 1053, inode table at 7201
           32768 free blocks, 8192 free inodes, 0 used directories, 8192 unused inodes
           [Inode not init, Block not init, Checksum 0x30ab]
 Group 13: block bitmap at 1038, inode bitmap at 1054, inode table at 7713
           32768 free blocks, 8192 free inodes, 0 used directories, 8192 unused inodes
           [Inode not init, Block not init, Checksum 0x8f81]
 Group 14: block bitmap at 1039, inode bitmap at 1055, inode table at 8225
           32768 free blocks, 8192 free inodes, 0 used directories, 8192 unused inodes
           [Inode not init, Block not init, Checksum 0x8aa2]
 Group 15: block bitmap at 1040, inode bitmap at 1056, inode table at 8737
           32768 free blocks, 8192 free inodes, 0 used directories, 8192 unused inodes
           [Inode not init, Block not init, Checksum 0x350d]
 Group 16: block bitmap at 524288, inode bitmap at 524304, inode table at 524320
           24544 free blocks, 8192 free inodes, 0 used directories, 8192 unused inodes
           [Inode not init, Checksum 0xb89c]

 

 

2.怎么查看flexbg包含16个block group

从上面的debugfs的group 显示结果可以看出,group 0至group 15的block bitmap,inode bitmap、inode table是连续存放的。而从group 16开始元数据不再连续了,这也说明flexbg为16个block group。

Category: 文件系统 | Tags: ext4 | Read Count: 1899

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com