首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“每个组的Inode”和"lazy_itable_init“标志与ext4文件系统中的"Inode计数”值有什么关系?

“每个组的Inode”和"lazy_itable_init“标志与ext4文件系统中的"Inode计数”值有什么关系?
EN

Unix & Linux用户
提问于 2022-05-11 11:57:13
回答 1查看 172关注 0票数 0

我正试图导致一个客户情况,其中两个相同的驱动器,使用相同的命令格式化,导致~55 in的总磁盘空间的差异,因为额外的Inode开销。

我想要理解

  1. 关于2 xInodes per group如何转换为2 xInode count的数学
  2. 使用Inodes per group标志时如何设置lazy_itable_init

Environment:

这两个驱动器在两个相同的硬件服务器上,运行在相同的操作系统上。以下是这两个驱动器的详细信息(敏感信息已编辑):

驱车A:

代码语言:javascript
复制
=== START OF INFORMATION SECTION ===
Vendor:               HPE
Product:              <strip>
Revision:             HPD4
Compliance:           SPC-5
User Capacity:        7,681,501,126,656 bytes [7.68 TB]
Logical block size:   512 bytes
Physical block size:  4096 bytes
LU is resource provisioned, LBPRZ=1
Rotation Rate:        Solid State Device
Form Factor:          2.5 inches
Logical Unit id:      <strip>
Serial number:        <strip>
Device type:          disk
Transport protocol:   SAS (SPL-3)
Local Time is:        Mon Apr 25 07:39:27 2022 GMT
SMART support is:     Available - device has SMART capability.

驱动B:

代码语言:javascript
复制
=== START OF INFORMATION SECTION ===
Vendor:               HPE
Product:              <strip>
Revision:             HPD4
Compliance:           SPC-5
User Capacity:        7,681,501,126,656 bytes [7.68 TB]
Logical block size:   512 bytes
Physical block size:  4096 bytes
LU is resource provisioned, LBPRZ=1
Rotation Rate:        Solid State Device
Form Factor:          2.5 inches
Logical Unit id:      <strip>
Serial number:        <strip>
Device type:          disk
Transport protocol:   SAS (SPL-3)
Local Time is:        Mon Apr 25 07:39:23 2022 GMT
SMART support is:     Available - device has SMART capability.

要格式化驱动器的命令是:

sudo mke2fs -F -m 1 -t ext4 -E lazy_itable_init,nodiscard /dev/sdc1

问题:

驱动器A和B的df -h输出分别显示尺寸为6.9T的DriveA和尺寸为7.0T的驱动器B:

代码语言:javascript
复制
/dev/sdc1       6.9T   89M  6.9T   1% /home/<strip>/data/<serial>
...
/dev/sdc1       7.0T  3.0G  6.9T   1% /home/<strip>/data/<serial>

Observations:

  • 两个驱动器上的fdisk输出显示它们都有相同的分区。

DriveA:

代码语言:javascript
复制
Disk /dev/sdc: 7681.5 GB, 7681501126656 bytes, 15002931888 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
Disk label type: gpt
Disk identifier: 70627C8E-9F97-468E-8EE6-54E960492318


#         Start          End    Size  Type            Name
 1         2048  15002929151      7T  Microsoft basic primary

DriveB:

代码语言:javascript
复制
Disk /dev/sdc: 7681.5 GB, 7681501126656 bytes, 15002931888 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
Disk label type: gpt
Disk identifier: 702A42FA-9A20-4CE4-B938-83D3AB3DCC49


#         Start          End    Size  Type            Name
 1         2048  15002929151      7T  Microsoft basic primary
  • /etc/mke2fs.conf内容在两个系统上都是相同的,因此这里没有有趣的事情:
代码语言:javascript
复制
================== DriveA =================
[defaults]
        base_features = sparse_super,filetype,resize_inode,dir_index,ext_attr
        enable_periodic_fsck = 1
        blocksize = 4096
        inode_size = 256
        inode_ratio = 16384

[fs_types]
        ext3 = {
                features = has_journal
        }
        ext4 = {
                features = has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,64bit
                inode_size = 256
        }
...
================== DriveB =================
[defaults]
        base_features = sparse_super,filetype,resize_inode,dir_index,ext_attr
        enable_periodic_fsck = 1
        blocksize = 4096
        inode_size = 256
        inode_ratio = 16384

[fs_types]
        ext3 = {
                features = has_journal
        }
        ext4 = {
                features = has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,64bit
                inode_size = 256
        }
  • 如果两个驱动器的tune2fs -l输出之间存在差异,则可以看到DriveA上的Inodes per group为2x DriveB。
  • 我们还看到Inode count在DriveA上是2xDriveB (完全不同的这里)
代码语言:javascript
复制
DriveA:
    Inode count:              468844544
    Block count:              1875365888
    Reserved block count:     18753658
    Free blocks:              1845578463
    Free inodes:              468843793
    ...
    Fragments per group:      32768
    Inodes per group:         8192
    Inode blocks per group:   512
    Flex block group size:    16
    
DriveB:
    Inode count:              234422272 <----- Half of A
    Block count:              1875365888
    Reserved block count:     18753658
    Free blocks:              1860525018
    Free inodes:              234422261
    ...
    Fragments per group:      32768
    Inodes per group:         4096 <---------- Half of A
    Inode blocks per group:   256  <---------- Half of A
    Flex block group size:    16
代码语言:javascript
复制
write_inode_tables(fs, lazy_itable_init, itable_zeroed);
...
static void write_inode_tables(ext2_filsys fs, int lazy_flag, int itable_zeroed)
...
    if (lazy_flag)
        num = ext2fs_div_ceil((fs->super->s_inodes_per_group - <--------- here
                       ext2fs_bg_itable_unused(fs, i)) *
                      EXT2_INODE_SIZE(fs->super),
                      EXT2_BLOCK_SIZE(fs->super));

如果将inode计数的差值乘以常量inode大小(256),则得到额外inode开销的(468844544-234422272)*256 = 60012101632 bytes ~55 get。

  1. 有人能帮我计算一下,当Inodes per group增加到2倍时,Inode计数是如何增加到2倍的吗?
  2. lazy_itable_init在运行时是否会影响到Inodes per group的值,如果是的话,我们如何才能理解它将设置什么值?(此标志是代码中唯一对s_inodes_per_group的引用)
EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2022-05-18 08:52:40

我发现这两种情况的差异是e2fsprogs版本的差异- 1.42.9和1.45.4。我没有想过要检查它,只依赖于mke2fs.conf文件。为这个明显的错过和感谢@lustreone的建议道歉。

我仍然很想知道与每个组的Inode和Inode计数有关的数学。

票数 0
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/702147

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档