The problem is that this operation is (always?) very slow:
something like 100 seconds (1 minute and 40 seconds). It has
been reproducible for several months. The logs show nothing
during this operation.
Any idea?
Maybe the directory is very large (even though its empty).
Try
ls -ld tmp.
and see if the file "tmp" is large.
Thanks! I didn't know that (I thought that the file system would
automatically "optimize" directories when files are removed, so
I've never looked closely at their size). Indeed:
ypig:~/eftests> ls -ld tmp
drwxr-xr-x 2 vlefevre vlefevre 29655040 2015-04-13 15:25:55 tmp/
Can someone please enlighten me as to why the entry for this
directory is so large, even though it is empty? Since it's
apparently obvious to everyone else, I would very much like to
know :)
A case study:
$ mkdir tmp
$ du -sxh tmp
4.0K tmp
$ for x in {1..100000}; do touch tmp/$x; done
$ du -sxh tmp
2.1M tmp
$ find tmp -type f | xargs rm
$ du -sxh tmp
2.1M tmp
$ ls tmp | wc -l
0
Removing files from the directory does not change directory's inode
size. If using ext4, at least.