------------------------------------------------------------------------------
MC logo
Linux File System
[^] CSc 422 Slides
------------------------------------------------------------------------------ Information from Sec. 10.6.
  1. The Virtual File System (VFS)
    1. Linux designed to support multiple file systems.
    2. The VFS is a layer on the OS that provides an interface.
      Similar to a Java interface or abstract class
    3. Each actual file system fills in virtual function methods.
    4. Supported file systems include native EXT-3 (or 4), FAT (still used on removable media) ISO-9660 (cd-roms), NTFS (that Window partition you might have lying around), and several other specialized ones.
    5. Abstract file operations structure.
  2. Ext-2
    1. An EXT sector is devided up into block groups.
    2. EXT sector layout.
      1. Superblock describes the whole FS: Size, group number and location, etc. Copies in each block group.
      2. Group descriptor describes the group: Size, locations of the other blocks, etc.
      3. Two bit maps describing free space, one for data blocks and one for i-nodes.
      4. I-node area, then the block area.
    3. I-Nodes
      1. Each file has one inode (index node) from which everything you need to know can be found.
      2. Inode format.
        1. Mode describes file permissons and some other things.
        2. Link count is how many directories refer to this file. That way the system knows when it's safe to delete it.
        3. Uid is a numerical code that maps to the owner.
        4. Gid is a numerical code that maps to a group in /etc/group.
        5. There are three times: last read, last write, last inode change for some other cause (usually permission change).
        6. Locations of data blocks as indicated.
        7. Indirect blocks are taken from the data area, but contain only the locations of other blocks (no user data).
      3. Arrangement favors small files, but allows very large ones.
    4. Directories.
      1. Directories are files with a special format.
      2. They contain a series of items mapping file name to inode number.
        The group info and i-node number are enough to find the inode.
      3. Directory format.
    5. Allocation Policy
      1. Block groups are designed to reduce fragmentation.
      2. If possible,
        1. When a file is created, allocate it's i-node in the same group as the directory block.
        2. Allocate the first data block in the same group as the i-node.
        3. Allocate additional data blocks in the same group as the last.
      3. To preserve some balance,
        1. Allocate subdirectory i-nodes in a different block from the parent directory block. (Choose one with relatively more free i-nodes.)
        2. When a file grows past a certain threshhold, deliberately switch to another group. (Choose one with relatively more free data blocks.)
      4. This tries to generally keep seeks inside the same block, while recognizing that this is not always possible.
      5. Limits file system utilization so the algorithm can work well.
    6. Basic block size can vary from 1K to 8K when formating. 4k seems most typical.
  3. EXT-3: Add journaling.
    1. Adds the journaling service to EXT-2. Really no other changes.
    2. Journal is a circular buffer of transactions.
    3. Journal may exist in a file, a disk, or a portion of a disk, either on the same device as the file system or another disk.
    4. Can journal just metadata (file system structural changes), or all changes to the fs (including data).
  4. EXT-4: Further extensions (source). These include:
    1. Extents: Instead of recording each block, a portion of a file may be a contiguous block of arbitrary size.
      1. Reduce table sizes.
      2. Reduce fragmentation.
    2. Files can grow by allocating multiple blocks instead of one at a time, and applications can request a pre-allocation of space.
      Reduce fragmentation
    3. Journal is checksummed to avoid errors. (And correct them?)