Skip to content

Commit 66f8e4d

Browse files
committed
Merge tag 'ext4_for_linus-6.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull ext4 bug fixes from Ted Ts'o: - Fix regression caused by removing CONFIG_EXT3_FS when testing some very old defconfigs - Avoid a BUG_ON when opening a file on a maliciously corrupted file system - Avoid mm warnings when freeing a very large orphan file metadata - Avoid a theoretical races between metadata writeback and checkpoints (it's very hard to hit in practice, since the race requires that the writeback take a very long time) * tag 'ext4_for_linus-6.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: Use CONFIG_EXT4_FS instead of CONFIG_EXT3_FS in all of the defconfigs ext4: free orphan info with kvfree ext4: detect invalid INLINE_DATA + EXTENTS flag combination ext4, doc: fix and improve directory hash tree description ext4: wait for ongoing I/O to complete before freeing blocks jbd2: ensure that all ongoing I/O complete before freeing blocks
2 parents 9b332ce + c065b60 commit 66f8e4d

File tree

111 files changed

+233
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+233
-212
lines changed

Documentation/filesystems/ext4/directory.rst

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ in the place where the name normally goes. The structure is
183183
- det_checksum
184184
- Directory leaf block checksum.
185185

186-
The leaf directory block checksum is calculated against the FS UUID, the
187-
directory's inode number, the directory's inode generation number, and
188-
the entire directory entry block up to (but not including) the fake
189-
directory entry.
186+
The leaf directory block checksum is calculated against the FS UUID (or
187+
the checksum seed, if that feature is enabled for the fs), the directory's
188+
inode number, the directory's inode generation number, and the entire
189+
directory entry block up to (but not including) the fake directory entry.
190190

191191
Hash Tree Directories
192192
~~~~~~~~~~~~~~~~~~~~~
@@ -196,37 +196,37 @@ new feature was added to ext3 to provide a faster (but peculiar)
196196
balanced tree keyed off a hash of the directory entry name. If the
197197
EXT4_INDEX_FL (0x1000) flag is set in the inode, this directory uses a
198198
hashed btree (htree) to organize and find directory entries. For
199-
backwards read-only compatibility with ext2, this tree is actually
200-
hidden inside the directory file, masquerading as “empty” directory data
201-
blocks! It was stated previously that the end of the linear directory
202-
entry table was signified with an entry pointing to inode 0; this is
203-
(ab)used to fool the old linear-scan algorithm into thinking that the
204-
rest of the directory block is empty so that it moves on.
199+
backwards read-only compatibility with ext2, interior tree nodes are actually
200+
hidden inside the directory file, masquerading as “empty” directory entries
201+
spanning the whole block. It was stated previously that directory entries
202+
with the inode set to 0 are treated as unused entries; this is (ab)used to
203+
fool the old linear-scan algorithm into skipping over those blocks containing
204+
the interior tree node data.
205205

206206
The root of the tree always lives in the first data block of the
207207
directory. By ext2 custom, the '.' and '..' entries must appear at the
208208
beginning of this first block, so they are put here as two
209209
``struct ext4_dir_entry_2`` s and not stored in the tree. The rest of
210210
the root node contains metadata about the tree and finally a hash->block
211211
map to find nodes that are lower in the htree. If
212-
``dx_root.info.indirect_levels`` is non-zero then the htree has two
213-
levels; the data block pointed to by the root node's map is an interior
214-
node, which is indexed by a minor hash. Interior nodes in this tree
215-
contains a zeroed out ``struct ext4_dir_entry_2`` followed by a
216-
minor_hash->block map to find leafe nodes. Leaf nodes contain a linear
217-
array of all ``struct ext4_dir_entry_2``; all of these entries
218-
(presumably) hash to the same value. If there is an overflow, the
219-
entries simply overflow into the next leaf node, and the
220-
least-significant bit of the hash (in the interior node map) that gets
221-
us to this next leaf node is set.
222-
223-
To traverse the directory as a htree, the code calculates the hash of
224-
the desired file name and uses it to find the corresponding block
225-
number. If the tree is flat, the block is a linear array of directory
226-
entries that can be searched; otherwise, the minor hash of the file name
227-
is computed and used against this second block to find the corresponding
228-
third block number. That third block number will be a linear array of
229-
directory entries.
212+
``dx_root.info.indirect_levels`` is non-zero then the htree has that many
213+
levels and the blocks pointed to by the root node's map are interior nodes.
214+
These interior nodes have a zeroed out ``struct ext4_dir_entry_2`` followed by
215+
a hash->block map to find nodes of the next level. Leaf nodes look like
216+
classic linear directory blocks, but all of its entries have a hash value
217+
equal or greater than the indicated hash of the parent node.
218+
219+
The actual hash value for an entry name is only 31 bits, the least-significant
220+
bit is set to 0. However, if there is a hash collision between directory
221+
entries, the least-significant bit may get set to 1 on interior nodes in the
222+
case where these two (or more) hash-colliding entries do not fit into one leaf
223+
node and must be split across multiple nodes.
224+
225+
To look up a name in such a htree, the code calculates the hash of the desired
226+
file name and uses it to find the leaf node with the range of hash values the
227+
calculated hash falls into (in other words, a lookup works basically the same
228+
as it would in a B-Tree keyed by the hash value), and possibly also scanning
229+
the leaf nodes that follow (in tree order) in case of hash collisions.
230230

231231
To traverse the directory as a linear array (such as the old code does),
232232
the code simply reads every data block in the directory. The blocks used
@@ -319,7 +319,8 @@ of a data block:
319319
* - 0x24
320320
- __le32
321321
- block
322-
- The block number (within the directory file) that goes with hash=0.
322+
- The block number (within the directory file) that lead to the left-most
323+
leaf node, i.e. the leaf containing entries with the lowest hash values.
323324
* - 0x28
324325
- struct dx_entry
325326
- entries[0]
@@ -442,12 +443,12 @@ The dx_tail structure is 8 bytes long and looks like this:
442443
* - 0x0
443444
- u32
444445
- dt_reserved
445-
- Zero.
446+
- Unused (but still part of the checksum curiously).
446447
* - 0x4
447448
- __le32
448449
- dt_checksum
449450
- Checksum of the htree directory block.
450451

451452
The checksum is calculated against the FS UUID, the htree index header
452453
(dx_root or dx_node), all of the htree indices (dx_entry) that are in
453-
use, and the tail block (dx_tail).
454+
use, and the tail block (dx_tail) with the dt_checksum initially set to 0.

arch/arc/configs/axs101_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ CONFIG_MMC_SDHCI=y
8888
CONFIG_MMC_SDHCI_PLTFM=y
8989
CONFIG_MMC_DW=y
9090
# CONFIG_IOMMU_SUPPORT is not set
91-
CONFIG_EXT3_FS=y
91+
CONFIG_EXT4_FS=y
9292
CONFIG_MSDOS_FS=y
9393
CONFIG_VFAT_FS=y
9494
CONFIG_NTFS_FS=y

arch/arc/configs/axs103_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ CONFIG_MMC_SDHCI=y
8686
CONFIG_MMC_SDHCI_PLTFM=y
8787
CONFIG_MMC_DW=y
8888
# CONFIG_IOMMU_SUPPORT is not set
89-
CONFIG_EXT3_FS=y
89+
CONFIG_EXT4_FS=y
9090
CONFIG_MSDOS_FS=y
9191
CONFIG_VFAT_FS=y
9292
CONFIG_NTFS_FS=y

arch/arc/configs/axs103_smp_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ CONFIG_MMC_SDHCI=y
8888
CONFIG_MMC_SDHCI_PLTFM=y
8989
CONFIG_MMC_DW=y
9090
# CONFIG_IOMMU_SUPPORT is not set
91-
CONFIG_EXT3_FS=y
91+
CONFIG_EXT4_FS=y
9292
CONFIG_MSDOS_FS=y
9393
CONFIG_VFAT_FS=y
9494
CONFIG_NTFS_FS=y

arch/arc/configs/hsdk_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ CONFIG_DMADEVICES=y
7777
CONFIG_DW_AXI_DMAC=y
7878
CONFIG_IIO=y
7979
CONFIG_TI_ADC108S102=y
80-
CONFIG_EXT3_FS=y
80+
CONFIG_EXT4_FS=y
8181
CONFIG_VFAT_FS=y
8282
CONFIG_TMPFS=y
8383
CONFIG_NFS_FS=y

arch/arc/configs/vdk_hs38_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ CONFIG_USB_OHCI_HCD_PLATFORM=y
7474
CONFIG_USB_STORAGE=y
7575
CONFIG_USB_SERIAL=y
7676
# CONFIG_IOMMU_SUPPORT is not set
77-
CONFIG_EXT3_FS=y
77+
CONFIG_EXT4_FS=y
7878
CONFIG_EXT4_FS=y
7979
CONFIG_MSDOS_FS=y
8080
CONFIG_VFAT_FS=y

arch/arc/configs/vdk_hs38_smp_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ CONFIG_MMC_DW=y
8181
CONFIG_UIO=y
8282
CONFIG_UIO_PDRV_GENIRQ=y
8383
# CONFIG_IOMMU_SUPPORT is not set
84-
CONFIG_EXT3_FS=y
84+
CONFIG_EXT4_FS=y
8585
CONFIG_MSDOS_FS=y
8686
CONFIG_VFAT_FS=y
8787
CONFIG_NTFS_FS=y

arch/arm/configs/axm55xx_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ CONFIG_MAILBOX=y
194194
CONFIG_PL320_MBOX=y
195195
# CONFIG_IOMMU_SUPPORT is not set
196196
CONFIG_EXT2_FS=y
197-
CONFIG_EXT3_FS=y
197+
CONFIG_EXT4_FS=y
198198
# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
199199
CONFIG_EXT4_FS=y
200200
CONFIG_AUTOFS_FS=y

arch/arm/configs/bcm2835_defconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ CONFIG_PWM_BCM2835=y
154154
CONFIG_EXT2_FS=y
155155
CONFIG_EXT2_FS_XATTR=y
156156
CONFIG_EXT2_FS_POSIX_ACL=y
157-
CONFIG_EXT3_FS=y
158-
CONFIG_EXT3_FS_POSIX_ACL=y
157+
CONFIG_EXT4_FS=y
158+
CONFIG_EXT4_FS_POSIX_ACL=y
159159
CONFIG_FANOTIFY=y
160160
CONFIG_MSDOS_FS=y
161161
CONFIG_VFAT_FS=y

arch/arm/configs/davinci_all_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ CONFIG_PWM=y
228228
CONFIG_PWM_TIECAP=m
229229
CONFIG_PWM_TIEHRPWM=m
230230
CONFIG_EXT2_FS=y
231-
CONFIG_EXT3_FS=y
231+
CONFIG_EXT4_FS=y
232232
CONFIG_EXT4_FS_POSIX_ACL=y
233233
CONFIG_XFS_FS=m
234234
CONFIG_AUTOFS_FS=m

0 commit comments

Comments
 (0)