ext4: fix large_dir directory index node split corruption

last updated 2022/08/21 16:00 UTC

affected systems

recommendation

security implication

steps to reproduce

  1. require a GNU/Linux system with python and 800GB+ free space
  2. as root
    1. create ext4 filesystem inside a file tmpfs
    2. enable large_dir
    3. mount it as tmpmnt
    fallocate -l 800G tmpfs
    mkfs -t ext4 tmpfs
    tune2fs -O large_dir tmpfs
    mount tmpfs tmpmnt
  3. prepare to write 32 million files by saving the following python script.py
    #!/bin/python
    i = 0
    while i <= 32000000:
        print (i)
        with open('tmpmnt/%d' % i, 'wb') as fout:
            i += 1
  4. run python script.py to completion
    1. observe broken behaviour (errno 17 EEXIST or 117 EUCLEAN)
      0
      1
      ...
      26369026
      26369027
      Traceback (most recent call last):
        File "tmpmnt/script.py", line 5, in <module>
          with open('tmpmnt/%d' % i, 'wb') as fout:
      FileExistsError: [Errno 17] File exists: 'tmpmnt/26369027'
    2. expected behaviour
      0
      1
      ...
      31999999
      32000000
  5. tidy up
    umount tmpmnt
    rm tmpfs script.py

the bug

suggested fix

funny memes

goto

open questions