]> git.ipfire.org Git - thirdparty/coreutils.git/commit
rm -r: avoid O(n^2) performance for a directory with very many entries
authorJim Meyering <meyering@redhat.com>
Mon, 22 Sep 2008 20:42:12 +0000 (22:42 +0200)
committerJim Meyering <meyering@redhat.com>
Fri, 26 Sep 2008 22:10:08 +0000 (00:10 +0200)
commit24412edeaf556a96a5ee122851de7c3e37726bdb
tree54240c2ae7944434cb6ef9ed2ff69ba6c964c78b
parenta5111af33ea6a5d27c3f7ab67afdb2a5884c38b6
rm -r: avoid O(n^2) performance for a directory with very many entries

This enhancement works around a problem that is specific to at least
ext3 and ext4 file systems.  With them, it would take hours to remove
a two-million-entry directory.  RAM-backed file systems (tmpfs) are
not affected, since there is no seek penalty.
* remove.c (rm_malloc, rm_free, compare_ino): New functions.
(dirent_count, preprocess_dir): New function.
[struct readdir_data]: New struct.
(remove_cwd_entries): Call preprocess_dir.
* tests/rm/ext3-perf: New file.  Test for the performance fix.
* NEWS: mention the new feature
NEWS
src/remove.c
tests/Makefile.am
tests/rm/ext3-perf [new file with mode: 0755]