i would like to show my apprentices the auto-defrag/perform mechanism from UFS. new FS, creating new directories, each directory get its own cylinder on the disk. hmm....
they want proofs.....
*embarrassing*
i couldn't remember how to look on which block the inode is linked....
so, please help me to keep my credibility (or perhabs my hono *hehe*)
I doubt that anyone walks around with those formulas in their head. But all of the macros are in /usr/include/sys/fs/ufs_*.h and you can get the raw data by using "fstyp -v".
what do you mean auto-defrag? as far as i know there is no defraging. if you mean how ufs allocates full block for largefiles first then allocates fragments for small files (i believe anything less then 2gb) first. but ufs does not have a defrag that i know about. you can specifiy what fragment size you want when createing the new fs bu the default is 1kb. each block can be devided into 1,2,4, or 8 fragments.
you might be able to use fstyp -v to figure out which cylinder your inode is on. do find out the inode you can use ls -i.
it wouldnt make much sense if each dir got a whole cylinder because each dir eats up an inode what if you have less inodes then you have cylinders?
Fragmentation in the context of this thread means a file that is scattered over the whole disk so that reading sequentially would be slow. This tends to not happen with the Berkeley filesystem because the file will be kept in one ccylinder group if possible.
There are only a few cylinder groups and each cg would have many inodes.
The allocation policy of the Berkeley filesystem reduces fragmentation enough that no de-fragging is needed.
Part of this policy days that a new directory goes to the least full cg. If you build a filesystem with, say 10 cg's, the root directory will be in cg 0. Now create exactly 9 more directories and each directory should be in a cylinder groups of it's own. This leads to stupid filesystem tricks like positioning a file exactly in the center cg for performance.
Getting the block of an inode is tricky but getting the cg is trivial. You divide the inode number by the inodes-per-cg and ignore the remainder.