Encountered a situation today on a server that has me wondering. Here's the scenario:
Syslog shows:
kernel: EXT3-fs warning (device sdb2): ext3_dx_add_entry: Directory index full!
Found the culprit to be a directory with 9.1 million files in it. I know it was 9 million files because I used this to delete them:
perl -e 'my $i=0;for(<*>){$i++;((stat)[9]<(unlink))} print "Files deleted: $i\n"'
Right after completion, I ran ls
- that took about 3 minutes, and returned 1 file.
A few minutes later, a fresh batch - again 9.1 million files have appeared in the same directory, and syslog showed again:
kernel: EXT3-fs warning (device sdb2): ext3_dx_add_entry: Directory index full!
I ran the delete again, and the exact same scenario repeated itself. Few minutes later, a new batch of over 9 million files.
The files that just appeared are old (about 3 months old).
Can someone confirm if this is the expected behavior of ext3?
- Directory index full is raised, well, when it's full
- New files are allowed to be created, but can't be added to the index
- New files are cached "somewhere"
- Once a slot is freed, the new file is added to the index (and hence will show up with e.g. ls)
I suspect that this is what's happening, but I currently don't have any proof.
Any feedback appreciated!
Please note the question isn't about how to fix it, it's about understanding what's happening here.