CS111 Lecture 11 Scribe Notes (Fall 13)

By: Dongkeun Lee


Some I/O Performance Metrics

Hypothetical Router Hash

Simplest

Method Latency (in microsecond) Throughput (in KB/s) CPU Utilization (%)
Polling: 1 Byte at a time 100 10 5
Batching 1000 21 10.5
Batching + Interrupt (Contect Switching)   106 18 8.9
DMA+Interrupt 61 91 45
DMA+Polling 56 162 84
**DMA: Direct Memory Access: Memory moves from Device Controller to RAM directly, not through CPU

File System Design

Eggert File System:

Table of Files DATA ... ... ...
One sector is consisted of useful data and leftover waste data
This is because one sector cannot be divided into smaller pieces, so if file takes up only a part of sector, the file system considers as if the file took up entire sector.
This is called, "Internal Fragmentation" and this is unavoiable in most cases

Table of Files:

11 Bytes 4 Bytes 10 Bytes
Sector Number Size Name

Advantage

  1. Simple - Only requires table to index and actual files
  2. Low Index Overhead - Does not take up much index space.
  3. Fast Sequential Access - File is stored sequentially, so there is no need for file system to look up where next sector is
  4. Fast Random Access
  5. Predictable Time - Time is predictable as file is stored sequentially

Disadvantage

  1. Internal Fragmentation - A sector cannot be divided into multiple smaller pieces
  2. External Fragmentation - File can only be stored sequentially, so there might be case where enough storage for file exists, but file system is not able to save the file, because there is not enough sequential sectors
  3. Directory Not Sorted - File system does not have any concept of directory
  4. File Growth Not Easy - File growth would mean that it has too find a set of sequential sectors that are bigger than current set. This means the entire file has to be moved into different location, instead of just adding few more sectors

File Allocation Table (FAT) File System

Developed in Late 1970s
Boot Sector Super Block FAT DATA ... ... ...

Sector vs Block

Block is a batch of sector, which is around the size of 4KiB, when sector is 512 bytes.
Basically block is used at software level, while sector is used at hardware level.

Boot Sector:

It contains bootstrapping programs which the Master Boot Record transfers to CPU
This allows CPU to know which program to boot up, when the computer is turned on.

Super Block Contains:

  1. File System Version
  2. Size of the File System
  3. Number of Sectors Used
  4. Root Directory Sector Location
  5. Other Metadata

File Allocation Table

Current Sector Next Sector
#1 27
#2 67
... ...

Directory in FAT

Directory is a file that maps file names into files
Name (11 Bytes) Size of File(4 Bytes) Type (At least 1 bit) Permission
Name section can have name of the file or another directory to allow nested directory.

How FAT works in basic

  1. Super block has location of where root directory is stored in the disk
  2. With root directory information, one can find file by searching through the directory
  3. Directory knows which file is associated with which sector, so file system would direct CPU to the corresponding sector number
  4. If newly read sector is directory, repeat above procedures and if it is a file, then read the sectors using FAT, since it stores the order in which sectors should be read

Problem of FAT System

FAT file would easily rename a file if it happens in a same directory.
However, moving a file to different directory will be burdensome as moving a file and deleting a file is two different system calls.
Therefore there is no gurantee that they will happen atomically.

Berkeley Fast File System (FFS) (~1975)

This file system is used by many Unix-based system
This file system adds another level of indirection in order to avoid the problem of FAT
Boot Sector Super Block Block Bitmap Inode Table DATA ... ... ...

Block Bitmap

Bitmap that tells the system which block is empty using 1 bit per block

Inode Table

Table has inodes ndexed by inode number
Each Inode consists of
Link Count
Owner
Group
Permission
...
Block Number
...
Block Number of List of Blocks

Directory

File Name (14 Bytes) Inode Number (2 Bytes)
Circular Links are disallowed as that would mass up link count.
However, FFS has better handling of renaming compared to FAT as FFS can link and unlink, instead of copying and deleting file.
FFS still has some errors that can be exploited, such as file not having name, but running on process and taking up huge number of blocks.

End of Lecture 11

Valid HTML 4.01 Transitional