[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: EXT3 and large directories



On Wed, Oct 04, 2006 at 06:43:22PM -0600, Andreas Dilger wrote:
> On Oct 04, 2006  16:33 -0500, Matt Dodson wrote:
> > I have an ext3 filesystem that has several directories and each
> > directory gets a large number of files inserted and then deleted over
> > time. The filesystem is basically used as a temp store before files are
> > processed. The issue is over time the directory scans get extremely slow
> > even if the directories are empty. I have noticed the directories can
> > range in size from 4k - 100M even when they are empty.  Is there a way
> > to fix this without recreating the directories or bringing the
> > filesystem offline? 
> 
> No way to fix this w/o offline e2fsck -fD.  ext3 doesn't shrink directories
> when deleting files.

Well, if there isn't anyone else using the directory, you can also do
the following:

	mkdir foo.new
	mv foo/* foo.new
	rmdir foo
	mv foo.new foo

And of course, if you know the directory is empty, just do:

	rmdir foo
	mkdir foo

Historically this is a pretty common restriction in Unix filesystems.
If someone cared enough, it would be possible to change ext3/4 to
release directory blocks when they are empty, but no one has found it
important enough to create such a patch.

						- Ted


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]