On Wed, 4 Apr 2001, Tom "Mad Dog" Yergeau wrote:
Okay, now I am really really confused.
Here's a summary of my understanding; maybe someone can point out where I'm off track.
- WAFL blocks are 4 KB
- Max # of inodes is one per 4 K block
- Each directory, even an empty one, fills at least one block
- But, up to 128 empty directories can be sqeezed into one block
This is slightly wrong. When you create a directory it gets a block allocated to it. The reason for this is that there really is no such thing as an empty directory. To demonstrate this do the following:
mkdir empty cd empty ls -la
The ls command will print out two items, "." and "..".
Now, based on the assumption that a directory block can hold 128 items, you can add 126 additionals items to the directory that you just created. If the items you create are additionals directories they will in turn each consume an inode and a data block. On the other hand, if you create a zero length file it does not consume any resources other than an inode and the small amount of space it takes in the existing directory block.
So, if you create a small number of directories and fill them with a huge number of files you will run out of inodes long before you run out of actual disk space. On the other hand if you create a huge number of directories you should run out of inodes and actual disk space at about the same time.
One caveat to all of this is that the assumption that you can fit 128 items into a directory block is just wrong. You can fit 128 inodes into a single 4K data block but a directory entry is not an inode. A directory entry consists of the name of the file and a pointer to the inode. The number of directory entries that you can fit into a single 4K directory block is dependant on the length of the filenames you create.