Skip to main content
Engineering LibreTexts

4.4: Block allocation

  • Page ID
    40727
  • File systems have to keep track of which blocks belong to each file; they also have to keep track of which blocks are available for use. When a new file is created, the file system finds an available block and allocates it. When a file is deleted, the file system makes its blocks available for re-allocation.

    The goals of the block allocation system are:

    • Speed: Allocating and freeing blocks should be fast.
    • Minimal space overhead: The data structures used by the allocator should be small, leaving as much space as possible for data.
    • Minimal fragmentation: If some blocks are left unused, or some are only partially used, the unused space is called “fragmentation”.
    • Maximum contiguity: Data that is likely to be used at the same time should be physically contiguous, if possible, to improve performance.

    It is hard to design a file system that achieves all of these goals, especially since file system performance depends on “workload characteristics” like file sizes, access patterns, etc. A file system that is well tuned for one workload might not perform as well for another.

    For this reason, most operating systems support several kinds of file systems, and file system design is an active area of research and development. In the last decade, Linux systems have migrated from ext2, which was a conventional UNIX file system, to ext3, a “journaling” file system intended to improve speed and contiguity, and more recently to ext4, which can handle larger files and file systems. Within the next few years, there might be another migration to the B-tree file system, Btrfs.

    • Was this article helpful?