From this question, which references this site, I understand that when an entry in a directory is deleted, the size of the previous entry is pushed to the next entry or to the end of the block depending on the case.

My question is, wouldn't that cause internal fragmentation? I imagine that if nothing is done, it could create a lot of wasted space. For example, if I have a very big directory from which I delete entries so that in every one of its data blocks I leave exactly one entry, that one entry is going to end up filling up the entire block. Then, I have x amount of blocks for x entries. But all of those entries could have been fitted in many fewer blocks.

Is this addressed at some point? Is the entry list defragmented? Or is it that when a new entry is inserted, a hole long enough is searched for? Also, what happens when the last entry in a block is deleted? Is the block freed and is the rest of the blocks reorganized in some way to fill in the null pointer in the directory inode?


You must log in to answer this question.

Browse other questions tagged .