首页 » 系统相关 » Troubleshooting kernel: EXT4-fs warning (device dm-0): ext4_dx_add_entry: Directory index full!

Troubleshooting kernel: EXT4-fs warning (device dm-0): ext4_dx_add_entry: Directory index full!

The following error message is displayed in the database host operating system log of a customer today.

kernel: EXT4-fs warning (device dm-0): ext4_dx_add_entry: Directory index full!

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[H-tree] structure which helps directory lookups for ext3/ext4 filesystem, improving performance for huge directories. XFS is B-tree.

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.

Resolution

  • 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.

Troubleshoot

As shown above is dm-0, what is dm-0? I will to demo many ways.

--RHEL 7 demo
# ls -l /dev/mapper
total 0
crw------- 1 root root 10, 236 Jun  5 09:30 control
lrwxrwxrwx 1 root root       7 Jun  5 09:30 ol-root -> ../dm-0
lrwxrwxrwx 1 root root       7 Jun  5 09:30 ol-swap -> ../dm-1

[root@localhost dev]# df
Filesystem          1K-blocks     Used Available Use% Mounted on
devtmpfs               872420        0    872420   0% /dev
tmpfs                  891852        0    891852   0% /dev/shm
tmpfs                  891852     8552    883300   1% /run
tmpfs                  891852        0    891852   0% /sys/fs/cgroup
/dev/mapper/ol-root  49250820 23477076  25773744  48% /
/dev/sda1             1038336   172976    865360  17% /boot
tmpfs                  178372        0    178372   0% /run/user/0

# dmsetup info /dev/dm-0
Name:              ol-root
State:             ACTIVE
Read Ahead:        8192
Tables present:    LIVE
Open count:        1
Event number:      0
Major, minor:      251, 0
Number of targets: 1
UUID: LVM-v7EXsgVrgQJVUMmoT2D4aCgTohMyqV7QAcNZ4PcmMqEzRhzK1xXQEBHHRISKybaq

# lvdisplay|awk '/LV Name/{n=$3} /Block device/{d=$3; sub(".*:","dm-",d); print d,n;}'
dm-1 swap
dm-0 root
or

[root@localhost mapper]# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    0   50G  0 disk
├─sda1        8:1    0    1G  0 part /boot
└─sda2        8:2    0   49G  0 part
  ├─ol-root 251:0    0   47G  0 lvm  /
  └─ol-swap 251:1    0    2G  0 lvm  [SWAP]
sr0          11:0    1 1024M  0 rom

[root@localhost mapper]# findmnt /
TARGET SOURCE              FSTYPE OPTIONS
/      /dev/mapper/ol-root xfs    rw,relatime,attr2,inode64,noquota

Note:
dm-0 is “/” mounted point.

How find the directory?

# cd /
# for dir in `ls -1`; do echo $dir; find ./$dir -type f|wc -l; done

How to rm file and dirs quickly(clear empty) ? It is usually not feasible to delete billions of files directly using rm.

[root@localhost ~]# mkdir dirs

[root@localhost ~]# cd dirs
[root@localhost dirs]# ls
[root@localhost dirs]# touch {0001..1000}.file
[root@localhost dirs]# ls
0001.file 0073.file 0145.file 0217.file 0289.file 0361.file 0433.file 0505.file 0577.file 0649.file 0721.file 0793.file 0865.file 0937.file
...
...
[root@localhost dirs]# perl -e 'for(<*>){((stat)[9]<(unlink))}'
[root@localhost dirs]# ls
[root@localhost dirs]# 

— enjob it —

 

 

 

References:

https://access.redhat.com/solutions/29894

打赏

, ,

目前这篇文章还没有评论(Rss)

我要评论