CSE 120 Operating Systems March 27, 2014 Lecture 17 Mass Storage Instructor: Neil Rhodes
Paging and Translation Lookaside Buffer frame dirty? no yes CPU checks TLB PTE in TLB? Free page frame? no yes OS instructs CPU to write the page to disk no Access page table y OS instructs CPU to read the page from disk CPU activates I/O hardware Page in main memory no CPU activates I/O hardware Page transferred from main memory to disk yes Update TLB Page transferred from disk to main memory Update page table return to failed instruction CPU generates physical address Update page table 2
Hardware Bus: a set of wires and protocol for communicating ISA PCI USB Memory bus Serial ATA Daisy chain: bus with cables going from one device to the next SCSI Firewire Main Memory Memory Bus PCI Bridge CPU Graphics Controller Monitor Keyboard Mouse USB Universal Serial Bus (USB) PCI Bus Disk Disk SCSI SCSI Bus Level 2 Cache IDE Disk Controller Disk Disk Disk Disk Daisy chain picture from <http://uk.geocities.com/dianne_davies/about-daisies.html> 3
Mass Storage Types Magnetic Disk Magnetic Tape Solid State Drive 4
Disks Hardware Track Disk Head Assembly Head Platter Sector Time to access a block (sector) Seek time (time to move the head in or out to the appropriate track) Rotational latency (time for the disk to spin so that the beginning of the sector is under the head) Transfer time (time for the data to be read from the sector). 5
Identifying a block Logical Block Number (LBN): 1-N Maps to: Cylinder/head/sector Who does the mapping? 6
Blocks written with ECC Blocks go bad Soft error Hard error Fixes: Sector sparing Sector slipping 7
Reading/Writing a block Seek first Wait for sector to rotate under head Read (or write) 8
Disk Specs Capacity Rotational Speed Western Digital VelociRaptor WD1500AHFD 1 TB 4 TB Seagate Desktop HDD 1.5 10,000 RPM 5,900 RPM Average rotational latency Average access time (seek + rotational) Average sustained transfer rate Buffer size 3 ms 4 ms 6.8 ms 17 ms 164 MB/s 132 MB/s 64 MiB 64 MiB 9
Disk Scheduling FCFS Shortest-seek time first (SSTF) SCAN (elevator) C-SCAN 10
RAID RAID: Redundant Array of Inexpensive Disks Compared to SLED: Single Large Expensive Disk Bunch of disks controlled by a RAID card Looks like SLED to the operating system, but provides better performance and better reliability Level 0 Striping Parallel read (for large read requests) Worse reliability Disk 1 Disk 2 Disk 3 Block 0-k LBN 0-k LBN k-2k LBN 2k-3k Block k-2k LBN 3k-4k LBN 4k-5k LBN 5k-6k Block 2k-3k LBN 6k-7k LBN 7k-8k LBN 8k-9k 11
RAID Level 1 Every strip is written twice Read from one disk while busy with another Disk 1 Disk 2 Disk 3 Disk 4 Disk 5 Disk 6 Block 0-k LBN 0-k LBN k-2k LBN 2k-3k LBN 0-k LBN k-2k LBN 2k-3k Block k-2k LBN 3k-4k LBN 4k-5k LBN 5k-6k LBN 3k-4k LBN 4k-5k LBN 5k-6k Block 2k-3k LBN 6k-7k LBN 7k-8k LBN 8k-9k LBN 6k-7k LBN 7k-8k LBN 8k-9k 12
RAID Level 2 Break each word into bits Add Hamming code Can correct any 1-bit error Can detect any 2-bit error Can lose any one drive Disks must be synchronized (rotation position and head location) Throughput increased by 16x Disk 1 Disk 2 Disk 3 Disk 18 Word 1 Err bit Err bit Bit 1 Bit 16 Word 2 Err bit Err bit Bit 1 Bit 16 Word 3 Err bit Err bit Bit 1 Bit 16 13
RAID Level 3 One extra parity drive Similar to level 2 Can t correct 1-bit errors Disk 1 Disk 2 Disk Disk 8 Disk 9 Bytes 0-7 Byte 0 Byte 1 Byte 7 XOR of bytes 0-7 Bytes 8-15 Byte 8 Byte 9 Byte 15 XOR of bytes 8-15 Bytes 16-31 Byte 16 Byte 17 Byte 31 XOR of bytes 16-31 14
RAID Level 4 Like level 0, but with extra parity drive One write, must re-read all strips to calculate parity Or, can pre-read old parity and data to compute new parity Parity drive may become bottleneck (used on every write) Can t correct 1-bit errors Disk 1 Disk 2 Disk 3 Disk 4 Block 0-k LBN 0-k LBN k-2k LBN 2k-3k Parity 0-3k Block k-2k LBN 3k-4k LBN 4k-5k LBN 5k-6k Parity 3k-6k Block 2k-3k LBN 6k-7k LBN 7k-8k LBN 8k-9k Parity 6K-9K 15
Level 5 RAID Like level 4, but with parity stripe spread across drives Disk 1 Disk 2 Disk 3 Disk 4 Block 0-k LBN 0-k LBN k-2k LBN 2k-3k Parity 0-3k Block k-2k LBN 3k-4k LBN 4k-5k Parity 3-6k LBN 5k-6k Block 2k-3k LBN 6k-7k Parity 6-9k LBN 7k-8k LBN 8k-9k 16