APPLIED[B/F/G/H]: [PATCH] Fix broken index hash with ext4 large_dir (LP: #1933074)

Kleber Souza kleber.souza at
Thu Jul 15 16:56:27 UTC 2021

On 06.07.21 15:36, Colin King wrote:
> From: Colin Ian King <colin.king at>
> BugLink:
> == SRU, Bionic, Focal, Groovy, Hirsute, Impish ==
> [Impact]
> Creating millions of files on ext4 partition with large_dir support
> by touching them will eventually trip an ext4 leaf node issue in the
> index hash. This occurs more frequently when also using smaller
> block sizes and ends up either with a EXIST or EUCLEAN failure.
> This occurs on the restart condition when performing do_split.
> [ Fix ]
> The fix protects do_split() from the restart condition, making it
> safe from both current and future ordering of goto statements in
> earlier sections of the code.
> The fix is from a patch sent upstream and cc'd to Ted Tso but didn't
> appear on the ext4 mailing list presumably because it got marked as SPAM.
> [ Test Case ]
> Without the fix touching tens of thousands of empty files will trip the
> issue. It seems to occur more frequently with memory pressure and
> smaller block sizes, e.g.:
> sudo mkdir -p /mnt/tmpfs /mnt/storage
> sudo mount -t tmpfs -o size=9000M tmpfs /mnt/tmpfs
> sudo dd if=/dev/urandom of=/mnt/tmpfs/ext4.img bs=1M
> sudo mkfs.ext4 -O large_dir -N 21000000 -O dir_index /mnt/tmpfs/ext4.img -b 1024 -F
> sudo mount /mnt/tmpfs/ext4.img /mnt/storage
> and compile and run the attached C program (see )
> that quickly populates /mnt/storage with empty files. Without the fix
> this will terminate with an -EEXIST or -EUCLEAN error on the file
> creation after several tens of thousands of files.
> [Where problems could occur]
> This changes the behaviour of the directory indexing hashing so there
> is a regression potential that this may introduce subsequent index
> hashing issues when needed (or not) to do a split. This patch seems to
> cover all the necessary cases, so I believe this risk is relatively low.
> I have also tested this on all the kernel series in the SRU with touching
> and removing over 20,000,000+ files so I am confident we have enough
> test coverage to show the fix is OK.
> Colin Ian King (1):
>    [UBUNTU][SAUCE][FOCAL] ext4: fix directory index node split corruption
>   fs/ext4/namei.c | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)

Applied to {bionic,focal,groovy,hirsute}:linux.


More information about the kernel-team mailing list