63
Mass storage Structure Unit 5 (Chapter 14)

Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Embed Size (px)

Citation preview

Page 1: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Mass storage Structure

Unit 5 (Chapter 14)

Page 2: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Disk Structures

• Magnetic disks are faster than tapes.• Disk drives are addressed as large one-

dimensional arrays of logical blocks , where the logical block is the smallest unit of transfer.

• The size of a logical block is usually 512 bytes, or 1,024 bytes.

• The one-dimensional array of logical blocks is mapped onto the sectors of the disk sequentially.

Page 3: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Disk structure

Page 4: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Disk structure• Sector 0 is the first sector of the first track on the outermost cylinder.

• The mapping proceeds in order through that track, then through the rest of the tracks in that cylinder, and then through the rest of the cylinders from outermost to innermost.

• By using this mapping, we can convert a logical block number in to a disk address – that consists of a cylinder number, a track number within that cylinder, and a sector number

within that track.

• In practice, it is difficult to perform this translation, for two reasons.

– First, most disks have some defective sectors, but the mapping hides this by substituting spare sectors from elsewhere on the disk

– Second, the number of sectors per track is not a constant on some drives.

Page 5: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Number of sectors per track is not a constant on some drives – WHY?

• Constant linear velocity (CLV) - the density of bits per track is uniform.– The farther a track is from the center of the disk, the

greater its length, so the more sectors it can hold.• As we move from outer zones to inner zones, the

number of sectors per track decreases.• Solution: The drive increases its rotation speed as the

head moves from the outer to the inner tracks to keep the same rate of data moving under the head (CD-ROM, DVD-ROM drives).

Page 6: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

• Alternatively, the disk rotation speed can stay

constant, and the density of bits decreases

from inner tracks to outer tracks to keep the

data rate constant.

• This method is used in hard disks and is known

as constant angular velocity (CAV)

Page 7: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Goals: Faster access time and large disk bandwidth

• The access time has two major components.– The seek time is the time for the disk arm to move the heads to the cylinder containing the

desired sector.– The rotational latency is the additional time for the disk to rotate the desired sector to the disk

head.

• The disk bandwidth– is the total number of bytes transferred, divided by the total time between the first request for

service and the completion of the last transfer

• We can improve both the access time and the bandwidth by scheduling the servicing of disk I/O requests in a good order.

• For a multiprogramming system with many processes, the disk queue may often have several pending requests

• Thus, when one request is completed, the OS chooses which pending Request to service next.• How does the OS make this choice?

• Solution: Disk-scheduling algorithms.

Page 8: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Disk Scheduling

• Several algorithms exist to schedule the servicing of disk I/O requests.

• We illustrate them with a request queue (0-199) for the blocks on cylinders

98, 183, 37, 122, 14, 124, 65, 67

Head pointer 53

Page 9: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Disk Scheduling

• Algorithms

– FCFS

– SSTF

– SCAN

– CSCAN

– LOOK

– CLOOK

Page 10: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Disk Scheduling: FCFS

98, 183, 37, 122, 14, 124, 65, 67

Page 11: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

FCFS: total head movement of 640 cylinders.

Page 12: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

FCFS

• Intrinsically fair

• But does not provide the fastest service

Page 13: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

SSTF (Shortest Seek Time First)

• Selects the request with the minimum seek

time from the current head position.

• SSTF scheduling is a form of SJF scheduling;

may cause starvation of some requests. Not

optimal.

Page 14: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Disk Scheduling: SSTF

98, 183, 37, 122, 14, 124, 65, 67

Page 15: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

SSTF exampleQueue Head pos Seek time

98 53 45183 53 13037 53 16

122 53 6914 53 39

124 53 7165 53 1267 53 14

SST= 12

Queue Head pos Seek time98 65 33

183 65 11837 65 28

122 65 5714 65 51

124 65 5967 65 2

SST= 2

Queue Head pos Seek time98 67 31

183 67 11637 67 30

122 67 5514 67 53

124 67 57

SST= 30

Queue Head pos Seek time98 37 61

183 37 146122 37 8514 37 23

124 37 87

SST= 23

Queue Head pos Seek time98 14 84

183 14 169122 14 108124 14 110

SST= 84

Queue Head pos Seek time183 98 85122 98 24124 98 26

SST= 24

Queue Head pos Seek time183 122 61124 122 2

SST= 2

Queue Head pos Seek time183 124 59

SST= 59

Page 16: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

SSTF: total head movement of 236 cylinders

Page 17: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

SCAN

• The disk arm starts at one end of the disk, and moves toward the other end, servicing requests until it gets to the other end of the disk, where the head movement is reversed and servicing continues.

• Sometimes called the elevator algorithm.

Page 18: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

SCAN

Page 19: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

SCAN: total head movement of 208 cylinders

Page 20: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

SCAN

• Assume a uniform density of requests.

• When a head reverses direction, there are relatively less requests, as these cylinders have been recently serviced.

• C-SCAN

Page 21: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

C-SCAN

• Provides a more uniform wait time than SCAN.

• The head moves from one end of the disk to the other, servicing requests as it goes. When it reaches the other end, however, it immediately returns to the beginning of the disk, without servicing any requests on the return trip.

• Treats the cylinders as a circular list that wraps around from the last cylinder to the first one.

Page 22: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

C-SCAN

Page 23: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

C-LOOK

• Version of C-SCAN

• Arm only goes as far as the last request in each direction, then reverses direction immediately, without first going all the way to the end of the disk.

• Looks for a request before continuing to move in a given direction LOOK

Page 24: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

C-LOOK

Page 25: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Selecting a Disk-Scheduling Algorithm

• SSTF is common and has a natural appeal

• a heavy load on the disk SCAN and C-SCAN.

• Performance depends on the number and types of requests.

• Requests for disk service can be influenced by the file-allocation method.

• The disk-scheduling algorithm should be written as a separate module, allowing it to be replaced if necessary.

• Either SSTF or LOOK is a reasonable choice for the default algorithm.

Page 26: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Disk Management

• Low-level formatting, or physical formatting — Dividing a disk into sectors that the disk controller can read and write.

• To use a disk to hold files, the operating system still needs to record its own data structures on the disk.– Partition the disk into one or more groups of

cylinders.– Logical formatting or “making a file system”.

Page 27: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Swap Space• Virtual memory

– Will use regular file system for at least reading code and data of program

– Partition formatted for swap space can give higher virtual memory performance

– Swap space on separate device or multiple devices• Swap space manager allocates/deallocates blocks

– Doesn’t use functions of normal file system– Maintain map(s) of swap space usage

• May handle text (code) & data differently– E.g., Solaris 1 – don’t swap text to swap disk; if page replacement

needs page, next time just re-read from normal file system; dirty data pages still written to swap disk as needed

Page 28: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Structure• RAID: Redundant Arrays of Independent Disks• RAID:

Multiple disk drives provides reliability via redundancy.• Redundancy:

– Mirroring (Shadowing): duplicate every disk, a logical disk consists of two physical disks, each write is done on both disks

– Number of reads are doubled as both disks are operative• To improve transfer rate:

– Data striping: – bit-striping: split the bits of each byte across multiple disks byte, sector, block level striping The number of disks is either a multiple of 8 or divides 8.

Page 29: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Structure

• To improve transfer rate:Data striping: split the bits of each byte across

multiple disks byte, sector, block level stripingBit-level striping:If 8 disks are there, bit i of a byte goes to disk i.Block-level striping:With n disks, block i of a file, goes to disk (i mod n+1).

Page 30: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Structure

• Potential drawbacks– Larger number of disks decreases mean-time-to-

failure (MTTF)• More disks provide more points of failure• Data stored in many RAID levels can be lost if more than

one drive in array fails

Page 31: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels

• Mirroring is expensive• Striping high data transfer rate, but

improved reliability• Different schemes, disk striping + parity bits,

gives different RAID levels• P – error correcting bits, C – copy of data• Six different RAID levels

Page 32: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels

Page 33: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels• Level 0

– Simplest RAID implementation– Includes striping but no redundancy (not a “true” RAID

level)– Highest-performing RAID level for a fixed number of disks– High risk of data loss

• Multiple drives involved• Could lose all data in array with one drive failure

– Appropriate where performance greatly outweighs reliability

Page 34: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels: 0

Logical DISK

0

1

2

3

4

5

6

7

8

9

10

11

Page 35: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels: 0

Page 36: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels• Level 0

– Block level stripingNotes:– If two different I/O requests are pending for two different

blocks of data, in all likelihood the two blocks are located in two different disks, then the requests can be issued in parallel

– If a single request is spread across multiple logically contiguous strips, the request can be handled in parallel

Page 37: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Level 1

– Highest level of redundancy/fault tolerance for traditional RAID levels– Each drive has a mirrored copy in array– No striping at this level

• Improves read performance over single disks because multiple disks can be read at once

• Slower write performance because two disks must be accessed for each modified data item to maintain mirroring

– High storage overhead• Only half array stores unique data

– Most suitable where reliability is primary concern

Page 38: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels: 1

Page 39: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels: 1

Page 40: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels: 1

Page 41: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels• Level 1

– Read request serviced by the disk which has minimum seek time

– Write speed = both disks to be updated, dictated by the slower of the two disks

– No “write penalty” involved– Suitable if bulk of the I/O requests are read– Limit RAID 1 to system software, and critical data

(real-time data)

Page 42: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels• Level 2

– Implements redundancy and striping• Striped at bit level• Uses Hamming ECC to check data integrity

– Parity bits store the evenness or oddness of a sum of bits– ECC data stored on separate drive– Significant overhead in storage (though less than level 1

arrays) and performance (due to calculating ECC data)– Not the most appropriate error checking method; ECC is

performed internally by most hard disks

• Rarely seen in modern systems

Page 43: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels 2

Page 44: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels 2

Page 45: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels 2

Page 46: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels• Level 2

– Read – all disks are simultaneously accessed– Write - all disks are simultaneously accessed

• Write penalty – computation of the Hamming ECC

– Used when many disk errors occur, but given the high reliability of individual disks, rarely used.

Page 47: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels• Level 3

– Also stripes at the bit level– Uses XOR to calculate parity for ECC

• Much simpler than Hamming ECC• Requires only one disk for parity information regardless

of the size of the array• Cannot determine which bit contains error, but this

information can be gathered easily by inspecting the array for a failed disk

• High transfer rates, but only one request serviced at a time

Page 48: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels 3

Page 49: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels 3

Page 50: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels• Level 3

– In the case of a disk failure,• All data are available missing data can be calculated

from the parity bit• Write: just maintain the parity such that later it can be

regenerated.• Failed disk to be replaced and the data regenerated

Page 51: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels• Level 4

– Similar to RAID level 3• Stores larger strips than other levels• Can service more requests simultaneously as files are

more likely to be on one disk• Write requests must be performed one at a time

– Restriction eliminated in level 5

• Rarely implemented because level 5 is similar but superior

Page 52: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels 4

Page 53: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels 4

Page 54: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels• Level 5

– Similar to level 4• Removes write bottleneck of RAID level 4, because

parity blocks are distributed across disks• Still must update parity information

– For many small write operations, overhead can be substantial– Caching mechanisms can help alleviate this

• Faster and more reliable than levels 2–4– Costlier and more complex as well– Among most commonly implemented RAID levels

Page 55: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels 5

Page 56: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels 5

Page 57: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels• Level 5

– For each block one of the disks stores parity, others store data

• 5 disks, parity of the nth block is stored in (n mod 5) +1 disk.

Potential overuse of the parity disk is avoided.

Page 58: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

• Level 6– Two different parity calculations are carried out

and stored in separate blocks on different disks– N disks N+2 Disks– Extreme high data availability, as three disks has

to fail simultaneously– High write penalty as two parity blocks are to be

updated.

Page 59: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels

Page 60: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID Levels• Other RAID levels exist

– No standard naming convention– RAID level 0+1: set of striped disks that are copied

to set of mirror disks– RAID level 1+0: set of mirrored data that is striped

across a set of disks– Others include 0+3, 0+5, 50, 1+5, 51, 53 and RAID

level 7

Page 61: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

RAID LevelsSelecting a RAID level:

• 0 – for high performance, data loss is not critical• 1 – high reliability and fast recovery• 0+1 and 1+0 – performance and reliability both important• 5 – for storing large volumes of data

Hot spare: a disk which readily replaces a failed disk. May be one of the mirrors.

Page 62: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Disk Management

• Boot block initializes system:– The bootstrap is stored in ROM.– Bootstrap program finds the OS kernel on disk– Bootstrap is stored on ROM– Problem of changing the bootstrap.– Tiny bootstrap loader which in turn loads the full

bootstrap program– Partition containing the bootstrap program is called

boot disk

Page 63: Mass storage Structure Unit 5 (Chapter 14). Disk Structures Magnetic disks are faster than tapes. Disk drives are addressed as large one- dimensional

Disk Management

• Bad block: One or more sectors are defective, these are called bad blocks.

• MS-DOS format: – do a logical format– Mark the bad blocks as unusable

• Sector sparing:– Low level formatting keeps spare sectors– Each bad sector is replaced with one such spare sector

• Sector Slipping: – Find the first available spare sector– Remap all sectors, moving down one spot.– Sector sparing: