What is the meaning of "ext[3/4]_dx_add_entry: Directory index full!"?
Environment
- Red Hat Enterprise Linux 5.6. or later
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
- Red Hat Enterprise Linux 9
- ext3 or ext4
Issue
- System log file contains the following messages (dependent on filesystem type ext3 or ext4):
kernel: EXT3-fs warning (device sdb1): ext3_dx_add_entry: Directory index full!
or
kernel: EXT4-fs warning (device dm-2): ext4_dx_add_entry: Directory index full!
- What does
ext[3/4]_dx_add_entry: Directory index full
mean?
Resolution
There are a number of possible resolutions:
- Determine if a process is creating unexpected or unwanted files or directories.
- Remove unnecessary or unwanted files or directories.
- Reorganize files and directories within the filesystem to reduce the number of entries in each individual directory.
- Use shorter filenames.
- Change the block size of the filesystem. This option requires a re-format of the filesystem, since the block size cannot be changed once it is set.
CAUTION: Before re-formatting the filesystem backup any important files to another device as reformatting will recreate the filesystem metadata and not retain information about existing files. By default the ext3 block size for small volumes is 1024. If possible format the disk with 4096 bytes (4k) block size as follows:
# mkfs -t ext3 -b 4096 /dev/device
- Disable
dir_index
option of the filesystem.
Note: There is no need to unmount the file system.
CAUTION: Disabling this option may impact performance on lookups in large directories.
# tune2fs -O ^dir_index /dev/device
- To recreate the
dir_index
:
# umount /dev/device
# tune2fs -O dir_index /dev/device
# e2fsck -D /dev/device
- Optimize directories in filesystem.
# man e2fsck
...
-D Optimize directories in filesystem. This option causes e2fsck to try to optimize all directories, either by
reindexing them if the filesystem supports directory indexing, or by sorting and compressing directories
for smaller directories, or for filesystems using traditional linear directories.
Even without the -D option, e2fsck may sometimes optimize a few directories --- for example, if directory
indexing is enabled and a directory is not indexed and would benefit from being indexed, or if the index
structures are corrupted and need to be rebuilt. The -D option forces all directories in the filesystem to be
optimized. This can sometimes make them a little smaller and slightly faster to search, but in practice, you
should rarely need to use this option.
The -D option will detect directory entries with duplicate names in a single directory, which e2fsck normally does
not enforce for performance reasons.
- To identify the directory, use the following
auditd
rule. You can get the audit log of the rule withausearch -m syscall -k for_ext3_dx_add_entry_warning
.
-a exit,always -F arch=b64 -S open -S openat -S creat -S link -S symlink -S mkdir -F exit=-ENOSPC -k for_ext3_dx_add_entry_warning
Root Cause
-
The 'directory index full' error will be seen if there are lots of files/directories in the filesystem so that the tree reaches its indexing limits and cannot keep track further.
-
The directory index is an additional tree structure which helps directory lookups, improving performance for huge directories.
-
There is a limit in ext3 and ext4 of the directory structure.
- A directory on ext3 can have at most 31998 sub directories, because an inode can have at most 32000 links. This is one cause of the warning.
- A directory on ext4 can have at most 64000 sub directories.
-
The size of each section of a directory index is limited by the filesystem's block size. If very long filenames are used, fewer entries will fit in the block, leading to 'directory index full' errors earlier than they would occur with shorter filenames. This can become a bigger problem when the filesystem's block size is small (1024-byte or 2048-byte blocks), but will occur with 4096-byte blocks as well.
-
For further information about directory indexing, you may refer to the following page : http://ext2.sourceforge.net/2005-ols/paper-html/node3.html
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
2 Comments
mxdcsdrpfidb01 kernel: EXT3-fs (dm-26): warning: ext3_dx_add_entry: Directory index full!
How can i know, which device is causing this error? apparently i dont have any dm-26 disk
[root@01 ~]# cd /dev/dm-
dm-0 dm-10 dm-12 dm-14 dm-16 dm-18 dm-2 dm-21 dm-23 dm-25 dm-4 dm-6 dm-8
dm-1 dm-11 dm-13 dm-15 dm-17 dm-19 dm-20 dm-22 dm-24 dm-3 dm-5 dm-7 dm-9
Ahoy folks,
Realizing the question is now rather old, it remained unanswered.
For the sake of posterity (as I had similar issue), this is the method found useful to locate the device at issue.
This will display a nicely formatted list of devices which you can then
grep
against or look at as a whole.Hope this helps!