group_descr.rst 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. .. SPDX-License-Identifier: GPL-2.0
  2. Block Group Descriptors
  3. -----------------------
  4. Each block group on the filesystem has one of these descriptors
  5. associated with it. As noted in the Layout section above, the group
  6. descriptors (if present) are the second item in the block group. The
  7. standard configuration is for each block group to contain a full copy of
  8. the block group descriptor table unless the sparse\_super feature flag
  9. is set.
  10. Notice how the group descriptor records the location of both bitmaps and
  11. the inode table (i.e. they can float). This means that within a block
  12. group, the only data structures with fixed locations are the superblock
  13. and the group descriptor table. The flex\_bg mechanism uses this
  14. property to group several block groups into a flex group and lay out all
  15. of the groups' bitmaps and inode tables into one long run in the first
  16. group of the flex group.
  17. If the meta\_bg feature flag is set, then several block groups are
  18. grouped together into a meta group. Note that in the meta\_bg case,
  19. however, the first and last two block groups within the larger meta
  20. group contain only group descriptors for the groups inside the meta
  21. group.
  22. flex\_bg and meta\_bg do not appear to be mutually exclusive features.
  23. In ext2, ext3, and ext4 (when the 64bit feature is not enabled), the
  24. block group descriptor was only 32 bytes long and therefore ends at
  25. bg\_checksum. On an ext4 filesystem with the 64bit feature enabled, the
  26. block group descriptor expands to at least the 64 bytes described below;
  27. the size is stored in the superblock.
  28. If gdt\_csum is set and metadata\_csum is not set, the block group
  29. checksum is the crc16 of the FS UUID, the group number, and the group
  30. descriptor structure. If metadata\_csum is set, then the block group
  31. checksum is the lower 16 bits of the checksum of the FS UUID, the group
  32. number, and the group descriptor structure. Both block and inode bitmap
  33. checksums are calculated against the FS UUID, the group number, and the
  34. entire bitmap.
  35. The block group descriptor is laid out in ``struct ext4_group_desc``.
  36. .. list-table::
  37. :widths: 1 1 1 77
  38. :header-rows: 1
  39. * - Offset
  40. - Size
  41. - Name
  42. - Description
  43. * - 0x0
  44. - \_\_le32
  45. - bg\_block\_bitmap\_lo
  46. - Lower 32-bits of location of block bitmap.
  47. * - 0x4
  48. - \_\_le32
  49. - bg\_inode\_bitmap\_lo
  50. - Lower 32-bits of location of inode bitmap.
  51. * - 0x8
  52. - \_\_le32
  53. - bg\_inode\_table\_lo
  54. - Lower 32-bits of location of inode table.
  55. * - 0xC
  56. - \_\_le16
  57. - bg\_free\_blocks\_count\_lo
  58. - Lower 16-bits of free block count.
  59. * - 0xE
  60. - \_\_le16
  61. - bg\_free\_inodes\_count\_lo
  62. - Lower 16-bits of free inode count.
  63. * - 0x10
  64. - \_\_le16
  65. - bg\_used\_dirs\_count\_lo
  66. - Lower 16-bits of directory count.
  67. * - 0x12
  68. - \_\_le16
  69. - bg\_flags
  70. - Block group flags. See the bgflags_ table below.
  71. * - 0x14
  72. - \_\_le32
  73. - bg\_exclude\_bitmap\_lo
  74. - Lower 32-bits of location of snapshot exclusion bitmap.
  75. * - 0x18
  76. - \_\_le16
  77. - bg\_block\_bitmap\_csum\_lo
  78. - Lower 16-bits of the block bitmap checksum.
  79. * - 0x1A
  80. - \_\_le16
  81. - bg\_inode\_bitmap\_csum\_lo
  82. - Lower 16-bits of the inode bitmap checksum.
  83. * - 0x1C
  84. - \_\_le16
  85. - bg\_itable\_unused\_lo
  86. - Lower 16-bits of unused inode count. If set, we needn't scan past the
  87. ``(sb.s_inodes_per_group - gdt.bg_itable_unused)``\ th entry in the
  88. inode table for this group.
  89. * - 0x1E
  90. - \_\_le16
  91. - bg\_checksum
  92. - Group descriptor checksum; crc16(sb\_uuid+group+desc) if the
  93. RO\_COMPAT\_GDT\_CSUM feature is set, or crc32c(sb\_uuid+group\_desc) &
  94. 0xFFFF if the RO\_COMPAT\_METADATA\_CSUM feature is set.
  95. * -
  96. -
  97. -
  98. - These fields only exist if the 64bit feature is enabled and s_desc_size
  99. > 32.
  100. * - 0x20
  101. - \_\_le32
  102. - bg\_block\_bitmap\_hi
  103. - Upper 32-bits of location of block bitmap.
  104. * - 0x24
  105. - \_\_le32
  106. - bg\_inode\_bitmap\_hi
  107. - Upper 32-bits of location of inodes bitmap.
  108. * - 0x28
  109. - \_\_le32
  110. - bg\_inode\_table\_hi
  111. - Upper 32-bits of location of inodes table.
  112. * - 0x2C
  113. - \_\_le16
  114. - bg\_free\_blocks\_count\_hi
  115. - Upper 16-bits of free block count.
  116. * - 0x2E
  117. - \_\_le16
  118. - bg\_free\_inodes\_count\_hi
  119. - Upper 16-bits of free inode count.
  120. * - 0x30
  121. - \_\_le16
  122. - bg\_used\_dirs\_count\_hi
  123. - Upper 16-bits of directory count.
  124. * - 0x32
  125. - \_\_le16
  126. - bg\_itable\_unused\_hi
  127. - Upper 16-bits of unused inode count.
  128. * - 0x34
  129. - \_\_le32
  130. - bg\_exclude\_bitmap\_hi
  131. - Upper 32-bits of location of snapshot exclusion bitmap.
  132. * - 0x38
  133. - \_\_le16
  134. - bg\_block\_bitmap\_csum\_hi
  135. - Upper 16-bits of the block bitmap checksum.
  136. * - 0x3A
  137. - \_\_le16
  138. - bg\_inode\_bitmap\_csum\_hi
  139. - Upper 16-bits of the inode bitmap checksum.
  140. * - 0x3C
  141. - \_\_u32
  142. - bg\_reserved
  143. - Padding to 64 bytes.
  144. .. _bgflags:
  145. Block group flags can be any combination of the following:
  146. .. list-table::
  147. :widths: 1 79
  148. :header-rows: 1
  149. * - Value
  150. - Description
  151. * - 0x1
  152. - inode table and bitmap are not initialized (EXT4\_BG\_INODE\_UNINIT).
  153. * - 0x2
  154. - block bitmap is not initialized (EXT4\_BG\_BLOCK\_UNINIT).
  155. * - 0x4
  156. - inode table is zeroed (EXT4\_BG\_INODE\_ZEROED).