next up previous
Next: Data Structures in Up: File Management Previous: Properties

Data Structures on Disk

A physical disk is divided into several logical disks. The components of a logical disk are discussed below.

Boot Block

The first sector on the logical disk is the boot block, containing a primary bootstrap program, which may be used to call a secondary bootstrap program residing in the next 7.5 kbytes.

Cylinder Group

The rest of the logical disk is composed of several cylinder groups. Each of these cylinder groups occupies one or more consecutive cylinders. The components of each cylinder group are discussed below.

Superblock

The superblock contains parameters of the logical disk, such as

total size of the logical disk

the block and fragment sizes

the inode number of the root directory

The superblock is identical in each cylinder group, so that it may be recovered from any one of them in the event of disk corruption. A superblock is not kept at the beginning of a cylinder group,

Thus a super block is stored at varying offset from the beginning of the cylinder group so that it is on a different platter from another superblock.

Cylinder Block

A cylinder block contains parameters of the cylinder group, such as:

bit map for free blocks and fragments,

bit map of free inodes

statistics of recent progress of allocation strategies

Inodes

There is an array of inodes in each cylinder group, which keeps header information about the files in the system. Each file name is associated with an inode, which contains the following information about the named object:

user and group identifiers of the object

time of last modification and access

number of aliases

type of the object (plain file, directory, indirect file, socket, or device)

fifteen pointers to data in the file, as discussed below.

The first twelve pointers directly point to data blocks. Thus, blocks of small files may be referenced with few disk accesses,

The next three data block pointers in the inode point to indirect blocks. The first of these is a single indirect block; that is, it points to a block that contains addresses of data blocks. The next is a double indirect block, which contains addresses of single indirect blocks. The third is a triple indirect block; it contains pointers to double indirect blocks. A minimum block size of 4096 bytes is supported so that files less than 2**32 bytes can be addressed without triple indirection. (if b is the minimum block size, then b/4*b/4*b = 2**32, since a block address is 4 bytes long). Files larger than this size cannot exist since file pointers are 4 bytes.

Data Blocks

The data blocks hold the data of both files and directories. Thus, at this level, there is no difference between a file and a directory. A directory contains a sequence of (filename, inode number) pairs. Thus to translate a file name, the system brings the inode of the root directory to memory, accesses its data blocks to find the inode of the next directory in the path, and so on, until it finds the inode of the named file.

Logical disks in Unix can be hierarchically arranged, in the sense that the root directory of one logical disk can be a subdirectory of a directory in another disk. Thus a path name "/u2/joe/foo" can span two disks, a disk that holds "/" and another that holds the tree rooted by "u2". In this situation the translation is more complex. When "u2" is encountered, the system discovers, through a bit in the inode for "u2" (the inode is stored in "/"), that another logical disk is mounted on this node. The system then refers to a mount table to find the device number of the new disk and the in-core copy of its superblock. The superblock is accessed to find the inode for the root directory of the disk, and this inode is used for "u2".


next up previous
Next: Data Structures in Up: File Management Previous: Properties



Prasun Dewan
Wed Apr 21 11:44:11 EDT 1999