CS441 S19 Mass - Storage PDF
CS441 S19 Mass - Storage PDF
Prof. Foley
Spring 2019 1
Announcements
Spring 2019 2
The I/O Problem
Spring 2019 3
General System Architecture
Peripherals – everything
else! Infrequent access,
devices are much
slower. (Keyboard,
mouse, external drives
and devices, storage)
Spring 2019 4
Modern System Architecture
Trends:
• Faster, fatter buses to
fastest devices
(memory, GPU)
• I/O chip dedicated to
managing I/O from
other devices
(network, storage,
slow connections)
• New faster versions
of buses to work with
the new architecture
(PCIe, eSATA)
Spring 2019 5
I/O Device
Spring 2019 6
Canonical Protocol
• An OS can tell the device what to do by issuing commands to the device. However,
commands can only be issued when the device is not busy with something else.
Spring 2019 7
Two ways to Check on a Device
• Polling
• Periodically check on the device to see if it is ready
• Pros:
• Simple
• Good for something that will happen fast
• Cons:
• Setting an appropriate time interval
• No overlap of I/O and computation
• Interrupts
• Main goal is to be able to do something productive while waiting
on I/O
• OS issues the request, calling process is put to sleep, context
switch to another task.
• When the device is ready, it issues a hardware interrupt.
Spring 2019 8
Interrupts
Spring 2019 9
More I/O Optimizations: DMA
Spring 2019 10
What is a driver?
• For the canonical device, we said the OS writes to the registers, but how does the
OS know how to write to those registers and what the commands are?
• OS has a basic API for dealing with devices that is exposed to the users (POSIX is
one such API)
• OS provides a generic device interface for reading and writing blocks of data to
devices
• Device drivers implement the specific interface to the devices based on the
generic API requests.
Spring 2019 11
Mass-Storage
Spring 2019 12
Mass Storage
Spring 2019 13
Mass-Storage
• Transfer Rate
• Rate of data flow between driver and
computer
• Positioning Time
• Seek time + rotational latency
• Seek Time:
• Time to move disk arm to desired cylinder
• Rotational Latency:
• Time for desired sector to rotate under the
disk head
• Bandwidth
• Rate of I/O transfer of sectors
• Head Crash
• Results from head making contact with
the disk surface
Spring 2019 14
Mass-Storage
Spring 2019 15
Operating System Support
• 2 major jobs of an OS
• Manage physical devices
• Present a virtual machine abstraction to applications
• For hard disks, OS provides 2 abstractions:
• Raw device: Array of data blocks
• File system: Queuing and scheduling of interleaved requests
from several applications
Spring 2019 22
Disk Structure
Spring 2019 23
Disk Structure
Spring 2019 24
Disk Scheduling
• If disk is available,
• Process request immediately
• Otherwise,
• Place request in queue
• OS chooses a pending request when disk becomes available
Improve both access time and bandwidth by managing the
order in which disk I/O requests are serviced
Spring 2019 26
Disk Scheduling
• Request Queue:
• Head: 53
• Queue: 98, 183, 37, 122, 14, 124, 65, 67 (Cylinders)
• Algorithms
• FCFS: First-Come, First-Served
• SSTF: Shortest-Seek-Time-First
• SCAN: a.k.a., Elevator Algorithm
• C-SCAN: Circular SCAN
• LOOK
• C-LOOK
Spring 2019 28
First-Come, First-Served (FCFS)
Spring 2019 29
First-Come, First-Served (FCFS)
• 53- 98 = 45
• 98-183 = 85
• 183- 37 = 146
• 37-122 = 85
• 122- 14 = 108
• 14-124 = 110
• 124- 65 = 59
• 65- 67 = 2
• Fair, but does not perform well due to wild swings between
cylinders (e.g., 122 to 14)
• Total Head Movement: 640 Cylinders (640/8 = 80)
Spring 2019 30
Shortest-Seek-Time-First (SSTF)
• Select request with the minimum seek time from the current
position
Spring 2019 31
Shortest-Seek-Time-First (SSTF)
• 53- 65 = 12
• 65- 67 = 2
• 67- 37 = 30
• 37- 14 = 23
• 14- 98 = 84
• 98-122 = 24
• 122-124 = 2
• 124-183 = 59
• Select request with the minimum seek time from the current
position – May cause starvation of some requests
• Total Head Movement: 236 Cylinders (236/8 = 29.5)
Spring 2019 32
Elevator (SCAN)
• Move disk arm from one end to the other servicing requests on the
way. Reverse direction on when you hit the other end
Spring 2019 33
Elevator (SCAN)
• 53- 37 = 16
• 37- 14 = 23
• 14- 0 = 14
• 0- 65 = 65
• 65- 67 = 2
• 67- 98 = 31
• 98-122 = 24
• 122-124 = 2
• 124-183 = 59
• Move disk arm from one end to the other servicing requests on the
way. Reverse direction on when you hit the other end
• Total Head Movement: 236 Cylinders (236/8 = 29.5)
Spring 2019 34
Circular Elevator (C-SCAN)
• Move disk arm from one end to the other servicing requests on
the way. Return to the beginning of the disk when you hit the
other end.
Spring 2019 35
Circular Elevator (C-SCAN)
• 53- 65 = 12
• 65- 67 = 2
• 67- 98 = 31
• 98-122 = 24
• 122-124 = 2
• 124-183 = 59
• 183-199 = 16
• 199- 0 = 199
• 0- 14 = 14
• 14- 37 = 23
• Move disk arm from one end to the other servicing requests on
the way. Return to the beginning of the disk when you hit the
other end. Results in a more uniform wait time
• Total Head Movement: 382 Cylinders (382/8 = 47.8)
Spring 2019 36
Circular Look (C-LOOK)
• Move disk arm from one end to the other servicing requests on the
way. Return to the first req. near the beginning of the disk when
you service the last request in that direction
Spring 2019 37
Circular Look (C-LOOK)
• 53- 65 = 12
• 65- 67 = 2
• 67- 98 = 31
• 98-122 = 24
• 122-124 = 2
• 124-183 = 59
• 183- 14 = 169
• 14- 37 = 23
• Move disk arm from one end to the other servicing requests on the
way. Return to the first req. near the beginning of the disk when
you service the last request in that direction
• Total Head Movement: 322 Cylinders (322/8 = 40.25)
Spring 2019 38
Selecting a Scheduling Algorithm
• Anticipatory Scheduling:
• Assume: An I/O request will be closely followed by another
nearby request
• After servicing a request – Wait!
• If a nearby request occurs soon, service it.
• If not, C-LOOK.
Spring 2019 40
Disk Management
Spring 2019 41
Disk Management
Spring 2019 42
Disk Management
Spring 2019 43
Swap-Space Management
• Swap-space:
Virtual memory using disk as an extension of main
memory
• Typically a separate disk partition
Spring 2019 44
Performance
• Sustained Bandwidth:
Avg. data rate during a large transfer
• Data rate when the data stream is actually flowing
• Effective Bandwidth:
Avg. over the entire I/O time
• Includes seek()/locate(), and cartridge switching
• Data rate provided by the drive
Spring 2019 45
Performance
• Access Latency:
Time needed to locate data
• Disk: (~5 milliseconds)
Move arm to the cylinder and wait for rotational latency
• Tape: (tens of seconds)
Winding tape reels until the selected block reaches the tape head
• If in a silo (jukebox) then we must add cartridge swapping time
[Could mean minutes]
Spring 2019 46
Disk Attachment
• Host-Attached Storage
Storage accessed through local I/O ports talk to I/O
busses
• SCSI, Fiber Channel, SATA
• Network-Attached Storage (NAS)
Storage made available over a network rather than a
local connection
• NFS, CIFS
• Storage-Area Network (SAN)
Private network connecting
severs and storage units
Spring 2019 47
Hardware Failures
Spring 2019 48
Hardware Failures
Spring 2019 49
Software Failures More on failure
Spring 2019 50
RAID
http://www.acnc.com/raidedu/0
• RAID:
Redundant Arrays of Independent Disks
• Improve reliability and, possibly, performance
• “A case for redundant arrays of inexpensive disks”,
Patterson, Gibson, Katz in 1988.
• Reliability through redundancy
• MTBF: Mean Time Between Failure
• 10x250 GB disks with MTBF of 100 years each would result in a
2.5 TB System with a MTBF of 100/10 = 10 years
• Mirroring:
Duplicate every disk.
• 1 logical disk = 2 physical disks, size of 1 physical disk
• Writes carried out twice
• Is there a performance benefit?
• Striping:
Use a group of physical disks as one larger, logical disk
• 1 logical disk = 2 physical disks, size of 2 physical disks
• Bit-level Striping:
Splitting the bits of each byte across multiple disks
• Block-level Striping: (Most common)
Splitting the blocks of a file across multiple disks
• Parity: (ECC)
An XOR calculation used to detect and recover from failures
Spring 2019 52
Error Correcting Codes (ECC)
Spring 2019 53
Parity Bits
• Even/Odd Parity
• Given a set of bits add one more bit as a checksum
• XOR each of the values in order, to determine even parity
• 100101 -> Parity bit 1
• 110011 -> Parity bit 0
Spring 2019 54
Parity Bits
• Even/Odd Parity
• Given a set of bits add one more bit as a checksum
• XOR each of the values in order, to determine even parity
• 100101 -> Parity bit 1
• 110011 -> Parity bit 0
Spring 2019 55
Parity Bits
• Even/Odd Parity
• Given a set of bits add one more bit as a checksum
• XOR each of the values in order, to determine even parity
• 100101 -> Parity bit 1
• 110011 -> Parity bit 0
Spring 2019 56
Parity Bits
Spring 2019 57
Parity Bits
Spring 2019 58
Parity Bits
Spring 2019 59
Parity Bits
11111011
Spring 2019 60
Parity Bits
11111011
10111111
10010001
01000000
Spring 2019 61
Parity Bits
video
RAID 0: Striping
• Break data into blocks, each block
written to a different disk
• Advantages:
• I/O performance improvement by
distributing I/O load
• Simple, easy
• Disadvantages:
• Not fault-tolerant!
Spring 2019 63
RAID Levels: RAID 1
RAID 1: Mirroring
• Duplicate data between disks
• Advantages:
• Fault-tolerant
• 2x Read transaction rate,
1x Write transaction
• Disadvantages:
• High disk overhead
(2 physical disks to 1 logical)
Spring 2019 64
RAID Levels: RAID 2
Spring 2019 65
RAID Levels: RAID 3
Spring 2019 66
RAID Levels: RAID 4
• Advantages:
• Requires all but one disk to operate.
• Good transfer rates
• Disadvantages:
• Requires N+1 disks (distributed parity)
• Cannot lose more than one disk at a time
• Difficult to rebuild after a failure
Spring 2019 68
RAID Levels: RAID 6
Spring 2019 69
RAID Levels: RAID 0+1 & 1+0
Spring 2019 70
Extensions
Spring 2019 71