brintos

brintos / linux-shallow public Read only

0
0
Text · 5.3 KiB · 392ec44 Raw
174 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3Block Group Descriptors4-----------------------5 6Each block group on the filesystem has one of these descriptors7associated with it. As noted in the Layout section above, the group8descriptors (if present) are the second item in the block group. The9standard configuration is for each block group to contain a full copy of10the block group descriptor table unless the sparse_super feature flag11is set.12 13Notice how the group descriptor records the location of both bitmaps and14the inode table (i.e. they can float). This means that within a block15group, the only data structures with fixed locations are the superblock16and the group descriptor table. The flex_bg mechanism uses this17property to group several block groups into a flex group and lay out all18of the groups' bitmaps and inode tables into one long run in the first19group of the flex group.20 21If the meta_bg feature flag is set, then several block groups are22grouped together into a meta group. Note that in the meta_bg case,23however, the first and last two block groups within the larger meta24group contain only group descriptors for the groups inside the meta25group.26 27flex_bg and meta_bg do not appear to be mutually exclusive features.28 29In ext2, ext3, and ext4 (when the 64bit feature is not enabled), the30block group descriptor was only 32 bytes long and therefore ends at31bg_checksum. On an ext4 filesystem with the 64bit feature enabled, the32block group descriptor expands to at least the 64 bytes described below;33the size is stored in the superblock.34 35If gdt_csum is set and metadata_csum is not set, the block group36checksum is the crc16 of the FS UUID, the group number, and the group37descriptor structure. If metadata_csum is set, then the block group38checksum is the lower 16 bits of the checksum of the FS UUID, the group39number, and the group descriptor structure. Both block and inode bitmap40checksums are calculated against the FS UUID, the group number, and the41entire bitmap.42 43The block group descriptor is laid out in ``struct ext4_group_desc``.44 45.. list-table::46   :widths: 8 8 24 4047   :header-rows: 148 49   * - Offset50     - Size51     - Name52     - Description53   * - 0x054     - __le3255     - bg_block_bitmap_lo56     - Lower 32-bits of location of block bitmap.57   * - 0x458     - __le3259     - bg_inode_bitmap_lo60     - Lower 32-bits of location of inode bitmap.61   * - 0x862     - __le3263     - bg_inode_table_lo64     - Lower 32-bits of location of inode table.65   * - 0xC66     - __le1667     - bg_free_blocks_count_lo68     - Lower 16-bits of free block count.69   * - 0xE70     - __le1671     - bg_free_inodes_count_lo72     - Lower 16-bits of free inode count.73   * - 0x1074     - __le1675     - bg_used_dirs_count_lo76     - Lower 16-bits of directory count.77   * - 0x1278     - __le1679     - bg_flags80     - Block group flags. See the bgflags_ table below.81   * - 0x1482     - __le3283     - bg_exclude_bitmap_lo84     - Lower 32-bits of location of snapshot exclusion bitmap.85   * - 0x1886     - __le1687     - bg_block_bitmap_csum_lo88     - Lower 16-bits of the block bitmap checksum.89   * - 0x1A90     - __le1691     - bg_inode_bitmap_csum_lo92     - Lower 16-bits of the inode bitmap checksum.93   * - 0x1C94     - __le1695     - bg_itable_unused_lo96     - Lower 16-bits of unused inode count. If set, we needn't scan past the97       ``(sb.s_inodes_per_group - gdt.bg_itable_unused)`` th entry in the98       inode table for this group.99   * - 0x1E100     - __le16101     - bg_checksum102     - Group descriptor checksum; crc16(sb_uuid+group_num+bg_desc) if the103       RO_COMPAT_GDT_CSUM feature is set, or104       crc32c(sb_uuid+group_num+bg_desc) & 0xFFFF if the105       RO_COMPAT_METADATA_CSUM feature is set.  The bg_checksum106       field in bg_desc is skipped when calculating crc16 checksum,107       and set to zero if crc32c checksum is used.108   * -109     -110     -111     - These fields only exist if the 64bit feature is enabled and s_desc_size112       > 32.113   * - 0x20114     - __le32115     - bg_block_bitmap_hi116     - Upper 32-bits of location of block bitmap.117   * - 0x24118     - __le32119     - bg_inode_bitmap_hi120     - Upper 32-bits of location of inodes bitmap.121   * - 0x28122     - __le32123     - bg_inode_table_hi124     - Upper 32-bits of location of inodes table.125   * - 0x2C126     - __le16127     - bg_free_blocks_count_hi128     - Upper 16-bits of free block count.129   * - 0x2E130     - __le16131     - bg_free_inodes_count_hi132     - Upper 16-bits of free inode count.133   * - 0x30134     - __le16135     - bg_used_dirs_count_hi136     - Upper 16-bits of directory count.137   * - 0x32138     - __le16139     - bg_itable_unused_hi140     - Upper 16-bits of unused inode count.141   * - 0x34142     - __le32143     - bg_exclude_bitmap_hi144     - Upper 32-bits of location of snapshot exclusion bitmap.145   * - 0x38146     - __le16147     - bg_block_bitmap_csum_hi148     - Upper 16-bits of the block bitmap checksum.149   * - 0x3A150     - __le16151     - bg_inode_bitmap_csum_hi152     - Upper 16-bits of the inode bitmap checksum.153   * - 0x3C154     - __u32155     - bg_reserved156     - Padding to 64 bytes.157 158.. _bgflags:159 160Block group flags can be any combination of the following:161 162.. list-table::163   :widths: 16 64164   :header-rows: 1165 166   * - Value167     - Description168   * - 0x1169     - inode table and bitmap are not initialized (EXT4_BG_INODE_UNINIT).170   * - 0x2171     - block bitmap is not initialized (EXT4_BG_BLOCK_UNINIT).172   * - 0x4173     - inode table is zeroed (EXT4_BG_INODE_ZEROED).174