Re: ext3/ext4 directories don't shrink after deleting lots of files

From: Timo Sirainen
Date: Fri May 15 2009 - 13:29:56 EST


On Fri, 2009-05-15 at 06:58 -0400, Theodore Tso wrote:
> > I was rather thinking something that I could run while the system was
> > fully operational. Otherwise just moving the files to a temp directory +
> > rmdir() + rename() would have been fine too.
> >
> > I just tested that xfs, jfs and reiserfs all shrink the directories
> > immediately. Is it more difficult to implement for ext* or has no one
> > else found this to be a problem?
>
> It's probably fairest to say no one has thought it worth the effort.

My problem is with mail servers and Maildir format where it's possible
that a user has tons of emails and wants to delete them. The mailbox
maybe slowly grows back to the huge size, but in the meantime it's
slower than necessary.

I can't really fix those directories while the system is running because
mail reading doesn't use any locking (and adding locking would be
unnecessary overhead). Writing does use locking though, so I could
create a new duplicate directory and switch it with the original
directory. But I suppose there's no way to atomically replace (or swap)
a non-empty directory with another?

Attachment: signature.asc
Description: This is a digitally signed message part