Transcription

Chapter 12: Mass 页: 5-52091022

Chapter 12: Mass-StorageSystems! Overview of Mass Storage Structure! Disk Structure! Disk Attachment! Disk Scheduling! Disk Management! Swap-Space Management! RAID Structure! Stable-Storage ImplementationOperating System Concepts14.2College of Software Engineering, Southeast University

Disk HardwareA Real HDD14.3College of Software Engineering, Southeast University

Overview of Mass Storage Structure! Magnetic disks provide bulk of secondarystorage of modern computersuDrives rotate at 60 to 250 times per seconduTransfer rate is rate at which data flow betweendrive and computeruPositioning time (random-access time) is timeto move disk arm to desired cylinder (seek time)and time for desired sector to rotate under thedisk head (rotational latency)uHead crash results from disk head makingcontact with the disk surfaceüThat’s badhttps://en.wikipedia.org/wiki/Hard disk drive performance charCollege of Software Engineering, Southeast University14.4acteristics#Rotational latency

Overview of Mass Storage Structure! Disks can be removable! Drive attached to computer via I/O busuBuses vary, including EIDE, ATA, SATA, USB,Fibre Channel, SCSI, SAS, FirewireuHost controller in computer uses bus to talk todisk controller built into drive or storage array! Platters of magnetic disks range from .85” to14” (historically)uCommonly 3.5”, 2.5”, and 1.8”! Range from 30GB to 3TB per drive14.5College of Software Engineering, Southeast University

Magnetic Disks! PerformanceuTransfer Rate – theoretical – 6revolutions per minute (RPM)Gb/secuEffective Transfer Rate – real – Typical HDD ncy [ms]uSeek time from 3ms to 12ms –4,2007.149ms common for desktop drives5,4005.56uAverage seek time measured or7,2004.17calculated based on 1/3 of tracks10,0003.0015,0002.00uLatency based on spindle speedü60s / RPM time per revolutionuAvg rotational latency ½ latency14.6(From Wikipedia)College of Software Engineering, Southeast University

Magnetic Disk Performance! Access Latency Average access time average seek time average rotational latencyuFor fastest disk 3ms 2ms 5msuFor slow disk 9ms 5.56ms 14.56ms! Average I/O time average access time (bytes to transfer / transfer rate) controlleroverheaduFor example to transfer a 4KB block on a 7200RPM disk with a 5ms average seek time, 1Gb/sectransfer rate, with a 0.1ms controller overhead,uAverage I/O time 5ms 4.17ms 4KB / 1Gb/sec 0.1ms 9.27ms 0.12ms 9.39ms14.7College of Software Engineering, Southeast University

Solid-State Disks! Nonvolatile memory used like a magnetic diskuMany technology variations! Can be more reliable than HDDs! More expensive per MB! Maybe have shorter life span than magnetic! Less capacity! But much faster! Buses can be too slow - connect directly toPCI for example! No moving parts, so no cylinder seek time orrotational latency14.8College of Software Engineering, Southeast University

Chapter 12: Mass-StorageSystems! Overview of Mass Storage Structure! Disk Structure! Disk Attachment! Disk Scheduling! Disk Management! Swap-Space Management! RAID Structure! Stable-Storage ImplementationOperating System Concepts14.9College of Software Engineering, Southeast University

Disk Structure! Disk drives are addressed as 1-dimensionalarrays of logical blocks, where the logical blockis the smallest unit of transfer.uLow-level formatting creates logical blocks onphysical media! The 1-dimensional array of logical blocks ismapped into the sectors of the disk sequentiallyuSector 0 is the first sector of the first track on theoutermost cylinder.uMapping proceeds in order through that track, thenthe rest of the tracks in that cylinder (WHY?), andthen through the rest of the cylinders fromoutermost to innermost.Operating System Concepts14.10College of Software Engineering, Southeast University

Chapter 12: Mass-StorageSystems! Overview of Mass Storage Structure! Disk Structure! Disk Attachment! Disk Scheduling! Disk Management! Swap-Space Management! RAID Structure! Stable-Storage ImplementationOperating System Concepts14.11College of Software Engineering, Southeast University

Disk Attachment! Host-attached storage accessed through I/Oports talking to I/O buses! SCSI itself is a bus, up to 16 devices on onecable, SCSI initiator requests operation andSCSI targets perform tasksuEach target can have up to 8 logical units, whichare addressed by logical unit number (LUN)! FC is high-speed serial architectureuCan be switched fabric with 24-bit address space– the basis of storage area networks (SANs) inwhich many hosts attach to many storage units! I/O directed to bus ID, device ID, logical unit14.12College of Software Engineering, Southeast University

Storage Array (存储阵列)! Can just attach disks, or arrays of disks! Storage array has controller(s), providesfeatures to attached host(s)uPorts to connect hosts to arrayuMemory, controlling software (sometimesNVRAM, etc)uA few to thousands of disksuRAID, hot spares, hot swap (discussed later)uShared storage --- higher efficiencyuFeatures found in some file systemsüSnapshots, clones, thin provisioning, replication,College of Software Engineering, Southeast University14.13deduplication, etc

Storage Area Network (存储局域网)! Common in large storage environments! Multiple hosts attached to multiplestorage arrays - ryclientserverLAN/WANdata-processingcenterweb contentproviderFiber Channel Switch14.14College of Software Engineering, Southeast Universityclientclient

Storage Area Network (Cont.)Today’s wifi802.11ac beamformingOptical fiber switch with switching fabric802.11abg, 802.11n, 802.11ac, 802.11adHigh-speed Ethernet 4th or 5th generationCore router/switch,mobile networksFDDI光纤令牌环网Core routerHigh speed switch14.15College of Software Engineering, Southeast University

Storage Area Network (Cont.)! SAN is one or more storage arraysuConnected to one or more Fibre Channel switches! Hosts also attach to the switches! Storage made available via LUN Maskingfrom specific arrays to specific servers! Easy to add or remove storage, add new hostand allocate it storageuOver low-latency Fibre Channel fabric! Why have separate storage networks andcommunications networks?uConsider FCOE, iSCSI14.16College of Software Engineering, Southeast University

Network-Attached StorageCombined storageand local areanetwork, based onFibre Channel overEthernet (FCoE)14.17College of Software Engineering, Southeast University

Network-Attached Storage! Network-attached storage (NAS) is storagemade available over a network rather thanover a local connection (such as a bus)uRemotely attaching to file systems! NFS and CIFS are common protocols! Implemented via remote procedure calls(RPCs) between host and storage overtypically TCP or UDP on IP network! iSCSI protocol uses IP network to carry theSCSI protocoluRemotely attaching to devices (blocks)14.18College of Software Engineering, Southeast University

Chapter 12: Mass-StorageSystems! Overview of Mass Storage Structure! Disk Structure! Disk Attachment! Disk Scheduling! Disk Management! Swap-Space Management! RAID Structure! Stable-Storage ImplementationOperating System Concepts14.19College of Software Engineering, Southeast University

Disk Scheduling! The operating system is responsible forusing hardware efficiently — for the diskdrives, this means having a fast access timeand a large disk bandwidth.! Disk bandwidth is the total number of bytestransferred, divided by the total timebetween the first request for service and thecompletion of the last transfer.Operating System Concepts14.20College of Software Engineering, Southeast University

Disk Scheduling (cont.)! Access time has three major componentsuSeek time is the time for the disk to move theheads to the cylinder containing the desiredsector.uRotational latency is the additional time waitingfor the disk to rotate the desired sector to thedisk head.uTransfer time is the time to transfer a block ofdata from the disk to the host computer.http://www.csc.villanova.edu/ /Hard disk drive performance characteristicsOperating System Concepts14.21College of Software Engineering, Southeast University

Disk Scheduling (cont.)! Here, we consider seek time as the mostdominate parameter, and attempt tominimize the seek timeuSeek time » seek distanceuAs hard disk seek time improves over time, itsrole as a bottleneck in hard disk performancediminishes and rotational delay will become amajor bottleneck in the not too distantfuture. Algorithms base not only on seek timereduction, but also on rotational distancereduction already exist in theory.http://www.csc.villanova.edu/ achang/diskintro.htmlOperating System Concepts14.22College of Software Engineering, Southeast University

Disk Scheduling (cont.)! Several algorithms exist to schedule theservicing of disk I/O requests.! We illustrate them with a request queue(falling into the range of 0 199).98, 183, 37, 122, 14, 124, 65, 67Head pointer 53Operating System Concepts14.23College of Software Engineering, Southeast University

FCFSIllustration shows total head movement of 640 cylinders.130146851081102Operating System Concepts5914.24College of Software Engineering, Southeast University

SSTF (Shortest Seek Time First)! Selects the request with the minimum seektime from the current head position.! SSTF scheduling is a form of SJFscheduling; may cause starvation of somerequests.! Illustration shows total head movement of236 cylinders.Operating System Concepts14.25College of Software Engineering, Southeast University

SSTF (cont.)14 53 169 236Operating System Concepts14.26College of Software Engineering, Southeast University

SCAN! The disk arm starts at one end of the disk,and moves toward the other end, servicingrequests until it gets to the other end of thedisk, where the head movement is reversedand servicing continues.! Sometimes called the elevator algorithm.! Illustration shows total head movement of236 cylinders.Operating System Concepts14.27College of Software Engineering, Southeast University

SCAN (cont.)53 183 236Operating System Concepts14.28College of Software Engineering, Southeast University

LOOK! Arm only goes as far as the last request ineach direction, then reverses directionimmediately, without first going all the way tothe end of the disk.! Illustration shows total head movement of208 cylinders.Operating System Concepts14.29College of Software Engineering, Southeast University

LOOK (cont.)39 169 208Operating System Concepts14.30College of Software Engineering, Southeast University

C-SCAN (Circular-SCAN)! Provides a more uniform wait time thanSCAN.! The head moves from one end of the diskto the other. Servicing requests as it goes.When it reaches the other end, however, itimmediately returns to the beginning of thedisk, without servicing any requests on thereturn trip.! Treats the cylinders as a circular list thatwraps around from the last cylinder to thefirst one.Operating System Concepts14.31College of Software Engineering, Southeast University

C-SCAN (cont.)Operating System Concepts14.32College of Software Engineering, Southeast University

C-LOOK! Version of C-SCAN! Arm only goes as far as the last request ineach direction, then reverses directionimmediately, without first going all the way tothe end of the disk.Operating System Concepts14.33College of Software Engineering, Southeast University

C-LOOK (cont.)Operating System Concepts14.34College of Software Engineering, Southeast University

Select a Disk-SchedulingAlgorithm! SSTF is common and has a natural appeal! SCAN and C-SCAN perform better for systemsthat place a heavy load on the diskuLess starvation! Performance depends on the number and typesof requests! Requests for disk service can be influenced bythe file-allocation methoduAnd metadata layoutOperating System Concepts14.35College of Software Engineering, Southeast University

Select a Disk-SchedulingAlgorithm (cont.)! The disk-scheduling algorithm should bewritten as a separate module of the operatingsystem, allowing it to be replaced with adifferent algorithm if necessary! Either SSTF or LOOK is a reasonable choicefor the default algorithm! What about rotational latency?uDifficult for OS to calculate! How does disk-based queuing effect OSqueue ordering efforts?Operating System Concepts14.36College of Software Engineering, Southeast University

Chapter 12: Mass-StorageSystems! Overview of Mass Storage Structure! Disk Structure! Disk Attachment! Disk Scheduling! Disk Management! Swap-Space Management! RAID Structure! Stable-Storage ImplementationOperating System Concepts14.37College of Software Engineering, Southeast University

Disk Formatting! Low-level formatting, or physical formatting— Dividing a disk into sectors that the diskcontroller can read and write.! To use a disk to hold files, the operatingsystem still needs to record its own datastructures on the disk.uPartition the disk into one or more groups ofcylinders.uLogical formatting or “making a file system”.Operating System Concepts14.38College of Software Engineering, Southeast University

Disk Formatting (1)A disk sectorOperating System Concepts14.39College of Software Engineering, Southeast University

Disk Formatting (2)An illustration of cylinder skewOperating System Concepts14.40College of Software Engineering, Southeast University

Disk Formatting (3)! No interleaving! Single interleaving! Double interleavingOperating System Concepts14.41College of Software Engineering, Southeast University

Error Handling! A disk track with a badsector! Substituting a sparefor the bad sector! Shifting all the s