ext4 块组介绍

Each block group on the filesystem has one of these descriptors associated with it. As noted in the Layout section above, the group descriptors (if present) are the second item in the block group. The standard configuration is for each block group to contain a full copy of the block group descriptor table unless the sparse_super feature flag is set.

Notice how the group descriptor records the location of both bitmaps and the inode table (i.e. they can float). This means that within a block group, the only data structures with fixed locations are the superblock and the group descriptor table. The flex_bg mechanism uses this property to group several block groups into a flex group and lay out all of the groups' bitmaps and inode tables into one long run in the first group of the flex group.

If the meta_bg feature flag is set, then several block groups are grouped together into a meta group. Note that in the meta_bg case, however, the first and last two block groups within the larger meta group contain only group descriptors for the groups inside the meta group.

flex_bg and meta_bg do not appear to be mutually exclusive features.

In ext2, ext3, and ext4 (when the 64bit feature is not enabled), the block group descriptor was only 32 bytes long and therefore ends at bg_checksum. On an ext4 filesystem with the 64bit feature enabled, the block group descriptor expands to at least the 64 bytes described below; the size is stored in the superblock.

If gdt_csum is set and metadata_csum is not set, the block group checksum is the crc16 of the FS UUID, the group number, and the group descriptor structure. If metadata_csum is set, then the block group checksum is the lower 16 bits of the checksum of the FS UUID, the group number, and the group descriptor structure. Both block and inode bitmap checksums are calculated against the FS UUID, the group number, and the entire bitmap.

The block group descriptor is laid out in struct ext4_group_desc.

OffsetSizeNameDescription
0x0__le32bg_block_bitmap_loLower 32-bits of location of block bitmap.
0x4__le32bg_inode_bitmap_loLower 32-bits of location of inode bitmap.
0x8__le32bg_inode_table_loLower 32-bits of location of inode table.
0xC__le16bg_free_blocks_count_loLower 16-bits of free block count.
0xE__le16bg_free_inodes_count_loLower 16-bits of free inode count.
0x10__le16bg_used_dirs_count_loLower 16-bits of directory count.
0x12__le16bg_flagsBlock group flags. Any of:
0x1inode table and bitmap are not initialized (EXT4_BG_INODE_UNINIT).
0x2block bitmap is not initialized (EXT4_BG_BLOCK_UNINIT).
0x4inode table is zeroed (EXT4_BG_INODE_ZEROED).
0x14__le32bg_exclude_bitmap_loLower 32-bits of location of snapshot exclusion bitmap.
0x18__le16bg_block_bitmap_csum_loLower 16-bits of the block bitmap checksum.
0x1A__le16bg_inode_bitmap_csum_loLower 16-bits of the inode bitmap checksum.
0x1C__le16bg_itable_unused_loLower 16-bits of unused inode count. If set, we needn't scan past the (sb.s_inodes_per_group - gdt.bg_itable_unused)th entry in the inode table for this group.
0x1E__le16bg_checksumGroup descriptor checksum; crc16(sb_uuid+group+desc) if the RO_COMPAT_GDT_CSUM feature is set, or crc32c(sb_uuid+group_desc) & 0xFFFF if the RO_COMPAT_METADATA_CSUM feature is set.
These fields only exist if the 64bit feature is enabled and s_desc_size > 32.
0x20__le32bg_block_bitmap_hiUpper 32-bits of location of block bitmap.
0x24__le32bg_inode_bitmap_hiUpper 32-bits of location of inodes bitmap.
0x28__le32bg_inode_table_hiUpper 32-bits of location of inodes table.
0x2C__le16bg_free_blocks_count_hiUpper 16-bits of free block count.
0x2E__le16bg_free_inodes_count_hiUpper 16-bits of free inode count.
0x30__le16bg_used_dirs_count_hiUpper 16-bits of directory count.
0x32__le16bg_itable_unused_hiUpper 16-bits of unused inode count.
0x34__le32bg_exclude_bitmap_hiUpper 32-bits of location of snapshot exclusion bitmap.
0x38__le16bg_block_bitmap_csum_hiUpper 16-bits of the block bitmap checksum.
0x3A__le16bg_inode_bitmap_csum_hiUpper 16-bits of the inode bitmap checksum.
0x3C__u32bg_reservedPadding to 64 bytes.

Total size is 64 bytes.

 
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值