Lec18 Filesystems
Lec18 Filesystems
April 3, 2006
Prof. Anthony D. Joseph
http://inst.eecs.berkeley.edu/~cs162
Track
Review: Magnetic Disk Sector
Characteristic
• Cylinder: all the tracks under the
head at a given point on all surface Head
• Read/write data is a three-stage Cylinder
process: Platter
– Seek time: position the head/arm over the proper track
(into proper cylinder)
– Rotational latency: wait for the desired sector
to rotate under the read/write head
– Transfer time: transfer a block of bits (sector)
under the read-write head
• Disk Latency = Queueing Time + Controller time +
Seek Time + Rotation Time + Xfer Time
Controller
Hardware
Request
Software
Result
Media Time
Queue
(Seek+Rot+Xfer)
(Device Driver)
• Highest Bandwidth:
– transfer large group of blocks sequentially from one track
4/3/06 Joseph CS162 ©UCB Spring 2006 Lec 18.2
Review: Building a File System
• File System: Layer of OS that transforms block
interface of disks (or other block devices) into Files,
Directories, etc.
• File System Components
– Disk Management: collecting disk blocks into files
– Naming: Interface to find files by name, not by blocks
– Protection: Layers to keep data secure
– Reliability/Durability: Keeping of files durable despite
crashes, media failures, attacks, etc
• User vs. System View of a File
– User’s view:
» Durable Data Structures
– System’s view (system call interface):
» Collection of Bytes (UNIX)
– System’s view (inside OS):
» Everything inside File System is in whole size blocks
» File is a collection of blocks (a block is a logical transfer
unit, while a sector is the physical transfer unit)
» Block size ≥ sector size; in UNIX, block size is 4KB
• File Systems
– Structure, Naming, Directories
File Header
Null
– Pros: Can grow files dynamically, Free list same as file
– Cons: Bad Sequential Access (seek between each block),
Unreliable (lose block, lose rest of file)
– Serious Con: Bad random access!!!!
– Technique originally from Alto (First PC, built at Xerox)
» No attempt to allocate contiguous blocks
Track Buffer
(Holds complete track)
– Solution1: Skip sector positioning (“interleaving”)
» Place the blocks from one file on every other block of a
track: give time for processing to overlap rotation
– Solution2: Read ahead: read next block right after first,
even if application hasn’t asked for it yet.
» This can be done either by OS (read ahead)
» By disk itself (track buffers). Many disk controllers have
internal RAM that allows them to read a complete track
• Important Aside: Modern disks+controllers do many
complex things “under the covers”
– Track buffers, elevator algorithms, bad block filtering
4/3/06 Joseph CS162 ©UCB Spring 2006 Lec 18.20
BREAK
How do we actually access files?
• All information about a file contained in its file header
– UNIX calls this an “inode”
» Inodes are global resources identified by index (“inumber”)
– Once you load the header structure, all the other blocks
of the file are locatable
• Question: how does the user ask for a particular file?
– One option: user specifies an inode by a number (index).
» Imagine: open(“14553344”)
– Better option: specify by textual name
» Have to map name→inumber
– Another option: Icon
» This is how Apple made its money. Graphical user
interfaces. Point to a file and click.
• Naming: The process by which a system translates from
user-visible names to system resources
– In the case of files, need to translate from strings
(textual names) or icons to inumbers/inodes
– For global file systems, data may be spread over globe⇒
need to translate from strings or icons to some
combination of physical server location and inumber
4/3/06 Joseph CS162 ©UCB Spring 2006 Lec 18.22
Directories
• Directory: a relation used for naming
– Just a table of (file name, inumber) pairs