Lecture 11: File System Design - 5/7/14

UCLA CS 111, Spring 2014 - Professor Eggert

Notes by Kailin Chang and Roger Chen

Table Of Contents

  1. Strategies For Improving File Systems

    1. Batching
    2. Pre-Fetching
    3. Speculation
    4. Dallying
    5. System Calls
  2. File System Design

    1. A Very Simple File System
    2. FAT File System
    3. UNIX File System

Strategies For Improving File Systems

Batching

To read data by sectors instead of by bytes.

Pre-Fetching (for reads)

To guess what the application will read next, even if the user has not accessed the block on the disk. In general, does more reading than what the current application asks for. This process occurs during runtime. There are 2 main types of guesses:
  1. Sequential Guess: if the application accesses i th block, it will probably access (i+1)th block
  2. Random Access Guess: turns off prefetching and clears cache more aggresively

Speculation

Relies on assumptions but improves performance in the long run.
  1. Spatial Locality: reading i th block means reading (i+1)th or (i-1)th block
  2. Temporal Locality: look at accesses over time, read i th block at time t means you'll read (i+1)th block at time t + ∂ (small delta)

Dallying (for writes)

Application says write(fd, buf, 1024) and OS returns 1024. Makes if possible for OS to batch or eliminate work entirely. However could cause problem: cache coherence. Cache coherence is demonstrated in the below diagram:
     -------                  -------------------
     | CPU |                  | Disk controller |      
     -------                  -------------------	
        |  Cache D4     													
 ===================================================  								
             |                      
          -------         --------      ---------
          | RAM | D3      | DATA | D1	| CACHE | D2
          -------         --------     	---------    
	

Notice that if D1 ≠ D2, power failure occurs.

System Calls

On a Unix file system:

File System Design

What is a file system?

A hybrid data structure:

A Very Simple File System

Specs: 1MB disk, 16 KB RAM

A general diagram of the overall file system:

 -----------------------------------------------------------------------------------------
 | Array of file names and locations | File data | .......... | File data 2 | .......... | 
 -----------------------------------------------------------------------------------------
 ** File data location is specified by the Offset and Size in the array of file names and locations (see below)
		

A closer look at the array of file names and locations:

 ----------------------------------
 |a|b|c| ....junk | Offset | Size | 
 ----------------------------------
		

Pros:

Cons:

** Good for realtime file system design because it is sequential and predictable

FAT File System

FAT: File Allocation Table

A general diagram of the overall file system:

 ----------------------------------------------------------
 | Boot Sector | Superblock | FAT (File Allocation Table) | 
 ----------------------------------------------------------
		

A closer look at each sector:

The Directory:

Pros:

Cons:

UNIX File System

A general diagram of the overall file system:

 --------------------------------------------------------------
 | Boot Block | Superblock | Inode Table | Data Blocks | .... |
 --------------------------------------------------------------
		

UNIX shares some similarities with the FAT file system, but has a new sector called the Inode Table.

A closer look at the Inode Table:

Unix Directory:

Pros:

Cons: