180 likes | 280 Views
Delve into the intricate workings of modern hard disk drives - from their interfaces to their intricate geometry and intelligent scheduling algorithms. Learn about the factors affecting performance and the evolution of disk technology.
E N D
Chapter 37. Hard Disk Drives Hyunjoon Kim(hjkim@theory.snu.ac.kr) School of Computer Science and Engineering Seoul National University
Introduction • Hard disk drive • Persistent data storage in computer systems • How do modern hard-disk drives store data? • What is the interface? • How is the data actually laid out and accessed? • How does disk scheduling improve performance?
The Interface to a Modern Disk Drive • The drive consists of a large number of sectors (512-byte blocks) • The address space of the drive with sectors • When a drive updates the disk, a single 512-byte write is atomic.
Basic Geometry Source: http://codex.cs.yale.edu/avi/os-book/OS9/slide-dir/ (retrieved on 2015/05/30) • The rate of rotation: rotations per minute (RPM) • 10,000 RPM = a single rotation takes 6 ms.
Multiple Tracks • When there is a request to read sector 11 • The drive has to first move the disk arm to the correct track: seek time • acceleration → coasting → deceleration → settling • It waits for the desired sector to rotate under the disk head: rotational delay • Data is either read from or written to the surface: transfer time
Some Other Details • Track skew • Sequential reads can be properly serviced when crossing track boundaries. • When switching from one track to another, the disk needs time to reposition the head.
Some Other Details Source: http://www.pcguide.com/ref/hdd/geom/tracksZBR-c.html (retrieved on 2015/05/31) • Outer tracks tend to have more sectors than inner tracks • Multi-zoned disk drives • A zone is consecutive set of tracks. • Each zone has the same number of sectors per track.
Some Other Details When the drive reads a sector 30 • When reading from a sector from the disk, • the drive reads all sectors on that track and caches them in the memory • for subsequent requests to the same track
Some Other Details When the drive writes a sector 30 Write through Write back 30 Disk drive The write has completed! • On writes, the drive acknowledges the write has completed • after the write has actually been written to disk (write through) • when it has put the data in the memory (write back) • Faster, but can be dangerous
I/O Time • Two types of workloads • Random workload • Sequential workload • A gap in performance between • random and sequential workloads • high-end “performance” drives and low-end “capacity” drives Comparison between drives: the rate of I/O
Disk scheduling • Given a set of I/O requests, the disk scheduler decides which one to schedule next. • It pick the one that will take the least time to service first. • It tries to follow the principle of SJF (shortest job first). • SSTF: Shortest Seek Time First • Elevator (SCAN or C-SCAN) • SPTF: Shortest Positioning Time First
SSTF: Shortest Seek Time First Requests: Starvation! Figure 37.7. SSTF: Scheduling Requests 21 And 2 • SSTF picks I/O requests on the nearest track to complete first. • The drive geometry is not available to the host OS. • Instead of SSTF, an OS can implement nearest-block-first (NBF) • Disadvantage • Starvation
Elevator (SCAN or C-SCAN) • SCAN simply moves across the disk servicing requests in order across the tracks. • If a request comes for a block on a track that has already been serviced on this sweep of the disk, it is queued until the next sweep. • sweep: a single pass across the disk • Variants • F-SCAN: freezes the queue to be serviced when it is doing a sweep. • Circular SCAN (C-SCAN): Instead of sweeping in one direction across the disk, the algorithm sweeps from outer-to-inner, and then inner-to-outer, etc. • Advantage • No starvation • Disadvantage • It does not adhere closely to the principle of SJF: it ignores rotation.
SPTF: Shortest Positioning Time First Figure 37.8. SSTF: Sometimes Not Good Enough. SPTF: Performs Better. • Should it schedule sector 16 or sector 8 for its next request? • It depends on the relative time of seeking as compared to rotation • If seek time >> rotational delay, then SSTF is fine. • If seek time ≤ rotational delay, it is better to service 8 →16. • In modern drives, seek time ≈ rotational delay • Advantage • Performance
Disk Scheduling in Modern Systems OS • Picks the best few requests. Issues them to disk. Disk • Uses its internal knowledge to service the requests in the best possible order. • Where is disk scheduling performed? • In older systems, the OS did all the scheduling. • In modern systems, disks accommodate multiple requests and have sophisticated internal schedulers. • Modern systems use a command queue: the program puts commands in the queue and does other things while the queue is processed by the hard disk drive. • Native Command Queuing (NCQ): SATA protocol allows disk drives to internally optimize the order in which received read/write commands are executed: this reduces unnecessary disk movement.
I/O Merging OS • Picks 33, 8, and 34. • Merges the requests for 33 and 34 into a single two-block request. Issues 33 and 8 to disk. Disk • Uses its internal knowledge to service the requests in the best possible order. For a series of requests to read blocks 33 → 8 → 34 It reduces the number of requests sent to the disk and lowers overheads.
Other Scheduling Issues • How long should the system wait before issuing an I/O to disk? • Work-conserving approach • Once it has a single I/O, the disk should immediately issue the request to the drive. • Non-work-conserving approach • Research on anticipatory disk scheduling (SitaramIyer, 2001) • Sometimes it is better to wait for a bit. • By waiting, a new and “better” request may arrive at the disk, and thus overall efficiency is increased.
Summary • The interface to a modern disk drive: read/write a sector • On cache write, • Write-through • Write-back • I/O time • Disk scheduling algorithms • SSTF: shortest seek time first • Elevator (SCAN or C-SCAN) • SPTF: Shortest Positioning Time First • Disk Scheduling in Modern Systems • Native Command Queuing (NCQ) • I/O merging