Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
43.  UFS File System (Reference) The Structure of Cylinder Groups for UFS File Systems The Superblock  Previous   Contents   Next 
   
 

Inodes

An inode contains all the information about a file except its name, which is kept in a directory. An inode is 128 bytes. The inode information is kept in the cylinder information block, and contains the following:

  • The type of the file:

    • Regular

    • Directory

    • Block special

    • Character special

    • FIFO, also known as named pipe

    • Symbolic link

    • Socket

    • Other inodes - attribute directory and shadow (used for ACLs)

  • The mode of the file (the set of read-write-execute permissions)

  • The number of hard links to the file

  • The user ID of the owner of the file

  • The group ID to which the file belongs

  • The number of bytes in the file

  • An array of 15 disk-block addresses

  • The date and time the file was last accessed

  • The date and time the file was last modified

  • The date and time the file was created

The array of 15 disk addresses (0 to 14) points to the data blocks that store the contents of the file. The first 12 are direct addresses; that is, they point directly to the first 12 logical storage blocks of the file contents. If the file is larger than 12 logical blocks, the 13th address points to an indirect block, which contains direct block addresses instead of file contents. The 14th address points to a double indirect block, which contains addresses of indirect blocks. The 15th address is for triple indirect addresses, if they are ever needed. The following figure shows this chaining of address blocks starting from the inode.

Figure 43-1 Address Chain for a UFS File System

Data Blocks

Data blocks, also called storage blocks, contain the rest of the space allocated to the file system. The size of these data blocks is determined at the time a file system is created. Data blocks are allocated, by default, in two sizes: an 8-Kbyte logical block size, and a 1-Kbyte fragment size.

For a regular file, the data blocks contain the contents of the file. For a directory, the data blocks contain entries that give the inode number and the file name of the files in the directory.

Free Blocks

Blocks that are not currently being used as inodes, as indirect address blocks, or as storage blocks are marked as free in the cylinder group map. This map also keeps track of fragments to prevent fragmentation from degrading disk performance.

To give you an idea of the appearance of a typical UFS file system, the following figure shows a series of cylinder groups in a generic UFS file system.

Figure 43-2 A Typical UFS File System

Custom File System Parameters

Before you choose to alter the default file system parameters that are assigned by the newfs command, you need to understand them. This section describes each of these parameters:

  • Logical block size

  • Fragment size

  • Minimum free space

  • Rotational delay

  • Optimization type

  • Number of files

Logical Block Size

The logical block size is the size of the blocks that the UNIX kernel uses to read or write files. The logical block size is usually different from the physical block size (usually 512 bytes), which is the size of the smallest block that the disk controller can read or write.

You can specify the logical block size of the file system. After the file system is created, you cannot change this parameter without rebuilding the file system. You can have file systems with different logical block sizes on the same disk.

By default, the logical block size is 8192 bytes (8 Kbytes) for UFS file systems. The UFS file system supports block sizes of 4096 or 8192 bytes (4 or 8 Kbytes). The recommended logical block size is 8 Kbytes


SPARC only - You can specify only the 8192-byte block size on the sun4u platform.


To choose the best logical block size for your system, consider both the performance desired and the available space. For most UFS systems, an 8-Kbyte file system provides the best performance, offering a good balance between disk performance and the use of space in primary memory and on disk.

As a general rule, to increase efficiency, use a larger logical block size for file systems where most of the files are very large. Use a smaller logical block size for file systems where most of the files are very small. You can use the quot -c file-system command on a file system to display a complete report on the distribution of files by block size.

 
 
 
  Previous   Contents   Next