I do not know how to return free space from a directory.
5MB is not a lot of space, so the easiest way to just ignore it. If this problem (files folding into a directory) occurs regularly, then this space will be reused at any time when the directory is full again.
If you desperately need the ability to compress a directory here (ugly) hack that might work.
Replace the directory with a symlink to the empty directory. If this problem persists, you can create a new empty directory and then change the symbolic link to point to the new directory. Changing a symbolic link must be atomic, so you wonβt lose incoming files. Then you can safely delete and delete the old directory.
[Edited to add: Turns out this doesn't work. As Bud notes in the comments, you cannot atomize the change of the symbolic link as I suggested. This leaves me from my original point of view. The file systems I am familiar with do not provide a mechanism for restoring free space in directory blocks.]
source share