Lec19 Filesystems2
Lec19 Filesystems2
April 5, 2006
Prof. Anthony D. Joseph
http://inst.eecs.berkeley.edu/~cs162
Review: Disk Scheduling
• Disk can do only one request at a time; What order do
you choose to do queued requests?
User
3,10
Head
2,2
5,2
7,2
2,1
2,3
Requests
• FIFO Order
– Fair among requesters, but order of arrival may be to
random spots on the disk ⇒ Very long seeks
• SSTF: Shortest seek time first
Disk Head
– Pick the request that’s closest on the disk 3
– Although called SSTF, today must include
rotational delay in calculation, since 2
1
rotation can be as long as seek
– Con: SSTF good at reducing seeks, but 4
may lead to starvation
• SCAN: Implements an Elevator Algorithm: take the
closest request in the direction of travel
– No starvation, but retains flavor of SSTF
• C-SCAN: Circular-Scan: only goes in one direction
– Skips any requests on the way back
– Fairer than SCAN, not biased towards pages in middle
4/5/06 Joseph CS162 ©UCB Spring 2006 Lec 19.2
Review: Access and Usage Patterns
• Access Pattern
– Sequential Access: bytes read in order (“give me the
next X bytes, then give me next, etc”)
» Almost all file access are of this flavor
– Random Access: read/write element out of middle of
array (“give me bytes i—j”)
» Less frequent, but still important. For example, virtual
memory backing file: page of memory stored in file
» Want this to be fast – don’t want to have to read all
bytes to get to the middle of the file
• Usage Pattern
– Most files are small (for example, .login, .c files)
» A few files are big – nachos, core files, etc.
» However, most files are small – .class’s, .o’s, .c’s, etc.
– Large files use up most of the disk space and bandwidth
to/from disk
» May seem contradictory, but a few enormous files are
equivalent to an immense # of small files
4/5/06 Joseph CS162 ©UCB Spring 2006 Lec 19.3
Review: Building File Systems
• 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
• Need way to structure files: File Header
– Track which blocks belong at which offsets within the
logical file structure
– Optimize placement of files disk blocks to match access
and usage patterns
• File System Design Goals:
– Maximize sequential performance
– Easy random access to file
– Easy management of file (growth, truncation, etc)
single board
host array disk
CPU
adapter controller controller
single board
disk
• Some systems duplicate controller
all hardware, namely
controllers, busses, etc. often piggy-backed
in small format devices
recovery
group
• Each disk is fully duplicated onto its "shadow“
– For high I/O rate, high availability environments
– Most expensive solution: 100% capacity overhead
• Bandwidth sacrificed on write:
– Logical write = two physical writes
– Highest bandwidth when disk heads and rotation fully
synchronized (hard to do exactly)
• Reads may be optimized
– Can have two independent reads to same data
• Recovery:
– Disk failure ⇒ replace disk and copy data to new disk
– Hot Spare: idle disk already attached to system to be
used for immediate replacement
4/5/06 Joseph CS162 ©UCB Spring 2006 Lec 19.25
RAID 5+: High I/O Rate Parity
Stripe
• Data stripped across Unit
multiple disks
D0 D1 D2 D3 P0
– Successive blocks
stored on successive Increasing
(non-parity) disks D4 D5 D6 P1 D7 Logical
Disk
– Increased bandwidth Addresses
over single disk D8 D9 P2 D10 D11
• Parity block (in green)
constructed by XORing D12 P3 D13 D14 D15
data bocks in stripe
– P0=D0⊕D1⊕D2⊕D3 P4 D16 D17 D18 D19
– Can destroy any one
disk and still
reconstruct data D20 D21 D22 D23 P5
– Suppose D3 fails, Disk 1 Disk 2 Disk 3 Disk 4 Disk 5
then can reconstruct:
D3=D0⊕D1⊕D2⊕P0
• Later in term: talk about spreading information widely
across internet for durability.
4/5/06 Joseph CS162 ©UCB Spring 2006 Lec 19.26
Remote File Systems: Virtual File System (VFS)