10
CS 346 – Chapter 10 Mass storage – Advantages? Disk features Disk scheduling Disk formatting Managing swap space – RAID

CS 346 – Chapter 10 Mass storage –Advantages? –Disk features –Disk scheduling –Disk formatting –Managing swap space –RAID

Embed Size (px)

Citation preview

Page 1: CS 346 – Chapter 10 Mass storage –Advantages? –Disk features –Disk scheduling –Disk formatting –Managing swap space –RAID

CS 346 – Chapter 10

• Mass storage– Advantages?– Disk features– Disk scheduling– Disk formatting– Managing swap space– RAID

Page 2: CS 346 – Chapter 10 Mass storage –Advantages? –Disk features –Disk scheduling –Disk formatting –Managing swap space –RAID

Disks

• Anatomy (Figure 10.1)– Sector, track, cylinder, platter

– Read/write head attached to arm, attached to arm assembly

– Head quickly reads binary data as: orientation of iron ions or reflectiveness of surface

• Example: CD– About 25,000 tracks, 50 sectors per track 1 bit occupies about 1

square m

– Entire CD can be read in about 7 minutes on a 12x speed drive

• But usually we don’t read entire disks2 aspects dominate access time:

– Seek time: proportional to square root of seek distance

– Rotational latency

Page 3: CS 346 – Chapter 10 Mass storage –Advantages? –Disk features –Disk scheduling –Disk formatting –Managing swap space –RAID

Some specs

Floppy disk Hard drive (2001) Hard drive (2011)

Cylinders 40 10 601 310 101

Tracks/cylinder 2 12 16

Sectors/track 9 281 (average) 63

Sectors/disk 720 35 742 000 312 500 000

Bytes/sector 512 512 512

Capacity 360 KB 18 GB 160 GB

Seek adjacent track 6 ms 0.8 ms

Seek (average) 77 ms 6.9 ms 9.5 ms

Rotation 200 ms 8.3 ms 8.3 ms

Transfer 1 sector 22 ms 17 s 1.7 s

Page 4: CS 346 – Chapter 10 Mass storage –Advantages? –Disk features –Disk scheduling –Disk formatting –Managing swap space –RAID

Disk scheduling

• Common problem is a backup of disk requests• Disk queue• When disk is ready, in what order should it do the disk

requests? Similar to problem of scheduling CPU• Pending jobs are classified by which track/cylinder they want to

access• Ex. 4, 7, 16, 2, 9, 1, 9, 5, 6• Several disk scheduling algorithms exist

– Simple approach: first-come, first-served– Total head movement = ?– Want to reduce total seeking time or head movement: avoid “wild

swings”.– Would be nice not to finish at extreme sector number.

Page 5: CS 346 – Chapter 10 Mass storage –Advantages? –Disk features –Disk scheduling –Disk formatting –Managing swap space –RAID

Scheduling (2)• Shortest seek first

– For 4, 7, 16, 2, 9, 1, 9, 5, 6: After serving track 4, where do we go next? Total head movement = ?

– Very good but not optimal

• Elevator algorithm (“scan” method)– Pick a direction and go all the way to end, then come back and handle all

other requests.– Better than Shortest Seek in our example?

• Circular scan– Same as elevator algorithm BUT: when you reach the end you

immediately go to the other end without stopping for requests. In other words, you only do work as head is moving in 1 direction.

• Look scheduling: modify elevator & circular scan so you only go as far as highest/lowest request

Page 6: CS 346 – Chapter 10 Mass storage –Advantages? –Disk features –Disk scheduling –Disk formatting –Managing swap space –RAID

Disk mgmt

• Low-level (physical) formatting– Dividing disk medium into sectors – Besides data, sector contains error-correcting code– Later, disk controller will manipulate individual sectors

• High-level (logical) formatting– Record a data structure for file system on disk– Partition groups of cylinders if desired– Associate adjacent blocks into logical clusters to support file I/O

• “Sector sparing”: compensate for bad blocks!– Maintain list of bad blocks; replace each with a spare one

• Boot from disk: boot blocks in predefined locations contain system code to load “boot partition” of drive

Page 7: CS 346 – Chapter 10 Mass storage –Advantages? –Disk features –Disk scheduling –Disk formatting –Managing swap space –RAID

Swap space

• Recall: used in virtual memory to store pages evicted from RAM– Faster to return to RAM than loading from file from scratch– In effect: disk space is now being used as extension of main

memory, the very essence of VM

• Logically a separate partition of the disk from the file system• When process started, it’s given some swap space• Swap map: kernel data structure to track usage

– Associate an counter value with each page in swap area– 0 means that page is available to swap into– Positive number: number of processes using that swapped-out data

(> 1 means it’s shared data)

Page 8: CS 346 – Chapter 10 Mass storage –Advantages? –Disk features –Disk scheduling –Disk formatting –Managing swap space –RAID

RAID

• Increasingly practical to have several disks on a system– But increases probability & mean time to failure

• RAID = “redundant array of independent disks”– Redundancy: fault tolerance technique

• Six “levels” or strategies of RAID: use various combinations of fault tolerant techniques

• Typical RAID techniques in use– Striping a group of disks: split bits of each byte across disks

Or block-level striping: split blocks of a file…– Mirroring another disk– Store parity (error-correcting) bits on another disk– Leaving some disks empty until needed to replace failed disk

Page 9: CS 346 – Chapter 10 Mass storage –Advantages? –Disk features –Disk scheduling –Disk formatting –Managing swap space –RAID

RAID levels

Various combinations of techniques… For example:• RAID 0 – block striping; no mirroring or parity bits• RAID 1 – add mirrored disks• RAID 2, 3, 4 – extra disks store parity bits

– If 1 disk fails, remaining bits of each byte and error-correction bit can be used to construct lot bit of each byte.

– RAID 3 – bit-interleaved parity– RAID 4 – block-interleaved parity

• RAID 0+1 – a set of disks is striped, and then the stripe is mirrored to another disk

• RAID 1+0 – disks are mirrored into a pair of disks. This pair is then striped.

Page 10: CS 346 – Chapter 10 Mass storage –Advantages? –Disk features –Disk scheduling –Disk formatting –Managing swap space –RAID

RAID extensions

• RAID is designed just to detect & handle disk failure• Does not prevent/detect data corruption, etc.

– Could be pointing to wrong file, wrong block

• Checksum for data and metadata on disk– Ex. For each disk block, how many bits are set?– Store with pointer to object (See Figure 10.13)– Detect whether it has changed. Grab correct data from the

mirror.

• RAID also somewhat inflexible because its techniques require a certain number of disks. What to do?