2020-09-23 09:21:41

by Mikulas Patocka

[permalink] [raw]
Subject: A bug in ext4 with big directories (was: NVFS XFS metadata)

Hi

There seems to be a bug in ext4 - when I create very large directory, ext4
fails with -ENOSPC despite the fact that there is plenty of free space and
free inodes on the filesystem.

How to reproduce:
download the program dir-test:
http://people.redhat.com/~mpatocka/benchmarks/dir-test.c

# modprobe brd rd_size=67108864
# mkfs.ext4 /dev/ram0
# mount -t ext4 /dev/ram0 /mnt/test
# dir-test /mnt/test/ 8000000 8000000
deleting: 7999000
2540000
file 2515327 can't be created: No space left on device
# df /mnt/test
/dev/ram0 65531436 633752 61525860 2% /mnt/test
# df -i /mnt/test
/dev/ram0 4194304 1881547 2312757 45% /mnt/test

(I tried to increase journal size, but it has no effect on this bug)

Mikulas


2020-09-23 09:45:53

by Jan Kara

[permalink] [raw]
Subject: Re: A bug in ext4 with big directories (was: NVFS XFS metadata)

Hi!

On Wed 23-09-20 05:20:55, Mikulas Patocka wrote:
> There seems to be a bug in ext4 - when I create very large directory, ext4
> fails with -ENOSPC despite the fact that there is plenty of free space and
> free inodes on the filesystem.
>
> How to reproduce:
> download the program dir-test:
> http://people.redhat.com/~mpatocka/benchmarks/dir-test.c
>
> # modprobe brd rd_size=67108864
> # mkfs.ext4 /dev/ram0
> # mount -t ext4 /dev/ram0 /mnt/test
> # dir-test /mnt/test/ 8000000 8000000
> deleting: 7999000
> 2540000
> file 2515327 can't be created: No space left on device
> # df /mnt/test
> /dev/ram0 65531436 633752 61525860 2% /mnt/test
> # df -i /mnt/test
> /dev/ram0 4194304 1881547 2312757 45% /mnt/test

Yeah, you likely run out of space in ext4 directory h-tree. You can enable
higher depth h-trees with large_dir feature (mkfs.ext4 -O large_dir). Does
that help?

Honza

--
Jan Kara <[email protected]>
SUSE Labs, CR

2020-09-23 12:48:02

by Mikulas Patocka

[permalink] [raw]
Subject: Re: A bug in ext4 with big directories (was: NVFS XFS metadata)



On Wed, 23 Sep 2020, Jan Kara wrote:

> Hi!
>
> On Wed 23-09-20 05:20:55, Mikulas Patocka wrote:
> > There seems to be a bug in ext4 - when I create very large directory, ext4
> > fails with -ENOSPC despite the fact that there is plenty of free space and
> > free inodes on the filesystem.
> >
> > How to reproduce:
> > download the program dir-test:
> > http://people.redhat.com/~mpatocka/benchmarks/dir-test.c
> >
> > # modprobe brd rd_size=67108864
> > # mkfs.ext4 /dev/ram0
> > # mount -t ext4 /dev/ram0 /mnt/test
> > # dir-test /mnt/test/ 8000000 8000000
> > deleting: 7999000
> > 2540000
> > file 2515327 can't be created: No space left on device
> > # df /mnt/test
> > /dev/ram0 65531436 633752 61525860 2% /mnt/test
> > # df -i /mnt/test
> > /dev/ram0 4194304 1881547 2312757 45% /mnt/test
>
> Yeah, you likely run out of space in ext4 directory h-tree. You can enable
> higher depth h-trees with large_dir feature (mkfs.ext4 -O large_dir). Does
> that help?

Yes, this helps.

Mikulas

>
> Honza
>
> --
> Jan Kara <[email protected]>
> SUSE Labs, CR

2020-09-23 20:24:01

by Andreas Dilger

[permalink] [raw]
Subject: Re: A bug in ext4 with big directories (was: NVFS XFS metadata)

[cut down CC list, since I don't think most people care about this detail]

On Sep 23, 2020, at 3:44 AM, Jan Kara <[email protected]> wrote:
>
> On Wed 23-09-20 05:20:55, Mikulas Patocka wrote:
>> There seems to be a bug in ext4 - when I create very large directory, ext4
>> fails with -ENOSPC despite the fact that there is plenty of free space and
>> free inodes on the filesystem.
>>
>> How to reproduce:
>> download the program dir-test:
>> http://people.redhat.com/~mpatocka/benchmarks/dir-test.c
>>
>> # modprobe brd rd_size=67108864
>> # mkfs.ext4 /dev/ram0
>> # mount -t ext4 /dev/ram0 /mnt/test
>> # dir-test /mnt/test/ 8000000 8000000
>> deleting: 7999000
>> 2540000
>> file 2515327 can't be created: No space left on device
>> # df /mnt/test
>> /dev/ram0 65531436 633752 61525860 2% /mnt/test
>> # df -i /mnt/test
>> /dev/ram0 4194304 1881547 2312757 45% /mnt/test
>
> Yeah, you likely run out of space in ext4 directory h-tree. You can enable
> higher depth h-trees with large_dir feature (mkfs.ext4 -O large_dir). Does
> that help?

You can also enable this feature on an existing filesystem by running
"tune2fs -O large_dir /dev/sdX". It might need to be unmounted, not sure.

Cheers, Andreas






Attachments:
signature.asc (890.00 B)
Message signed with OpenPGP