On Mon, Jun 10, 2024 at 1:55 PM Andreas Dilger <adilger@xxxxxxxxx> wrote: > > On Jun 7, 2024, at 10:25 AM, Nic Bretz <bretznic@xxxxxxxxx> wrote: > > > > When I create a new directory and new files in it, I see its size and > > blocks increase when running stat. After deleting all files, the size > > and blocks of the directory don't decrease in stat. > > Correct, ext4 does not shrink directories after they have been populated. > There was a patch series at https://patchwork.ozlabs.org/project/linux-ext4/patch/20190821182740.97127-1-harshadshirwadkar@xxxxxxxxx/ that fell > into a crack and was never landed. However, I think that patch would > still be interesting to revive. > > > I was thinking that ext4 runs defragmentation in the background and > > eventually those two numbers will decrease. It looks like they don't. > > No, ext4 does not do any kind of automatic background scanning or > filesystem changes. You can run (offline) "e2fsck -fD" if there is > a big problem with large empty directories. > > Cheers, Andreas > Thank you for taking the time to explain this. I was thinking to possibly start looking into this, but if there is already a patch, I'll study that. Nic