----- Original Message ----- From: "Chris Thompson" cet1@cus.cam.ac.uk To: "Tom "Mad Dog" Yergeau" MadDog@fool.com Cc: marty.johnson@erols.com; toasters@mathworks.com Sent: Wednesday, April 04, 2001 1:11 PM Subject: Re: Inodes a go go
MadDog@fool.com (Tom "Mad Dog" Yergeau) writes:
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
1-3 are right, but not 4. An "empty" directory (they are never really
empty,
of course, as they have entries for "." and ".." in them) still occupies one 4 KB block in WAFL.
The *pointers* to 128 empty directories (or to anything else) can be
"squeezed
into one block".
Right. In other words, 128 *directory entries* can be squeezed into one 4K block. What's a directory entry? Basically all the "filenames" of the files in a directory... so you files named "foo", "mbox", etc. all have their names stored in the 4K data block of the parent directory. Now, directories also have names, so like files, their name is stored in the 4K block of the parent.
So, even directory takes up 4K, minimum. If a directory has MORE than 128 entries... like a directory with 128 subdirectories all at the same level... then it gets allocated about 4K block.
One neat thing you can do is create a directory, fill it with a million files, then delete them all and you can still wind up with a directory that is megabytes in size but empty. Or at least you could. I think deleteing files "off the end" of the directory entry will actually shrink the directory size now, but you can fool this by not deleteing every 128th file. There's no automatic compression of "empty" directory entries. Unless that has changed too. Haven't tested it in ages. :)
Bruce