May 31st Lecture ================= Inode creation: * UFS1: static allocation - has to assume many small files, wastes space: 3% of HD reserved, <25% used by inodes - newfs operation very slow * UFS2: uses "dynamic" allocation; initially first 2 blocks per cylinder group are reserved for inodes. However when the filesystem fills, up, those unused blocks can be reclaimed for data use - suppose disk fills and we use the extra inode blocks - now we delete a large file and try to create multiple small files - no space for the inodes, even though plenty of room for file data Open a file: * Is inode in memory? Check inode table hashtable. * Request new vnode, allocate inode structure. * Locate disk block containing inode and load it Directories: * Really files themselves - have inode - have "data" (pointer data * Directory entry: - inode # - size of entry - type (file, directory) - filename length - filename, padded to 4 bytes When directory entries are remove, space is collected into last entry's padding; if first entry, inode is set to 0. Directory entries never span blocks (since we want single block updates on operations). Unused directory space is never compacted. When searching for a file, start at the root directory (which always has an inode # of 2) and drill down.