50
Joonwon Lee [email protected] IO and RAID

Joonwon Lee [email protected] IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

Embed Size (px)

Citation preview

Page 1: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

Joonwon [email protected]

IO and RAID

Page 2: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

2

Input/Output

5.1 Principles of I/O hardware5.2 Principles of I/O software5.3 I/O software layers5.4 Disks5.5 Clocks5.6 Character-oriented terminals5.7 Graphical user interfaces5.8 Network terminals5.9 Power management

Page 3: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

3

Device Controllers

• I/O devices have components:– mechanical component

– electronic component

• The electronic component is the device controller– may be able to handle multiple devices

• Controller's tasks– convert serial bit stream to block of bytes

– perform error correction as necessary

– make available to main memory

Page 4: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

4

Memory-Mapped I/O: merits

IN REG, PORTOUT PORT, REG

memory-mapped IO-all code can be written in C-test&set on control register

data buffer in memorycontrol registers are on ports

Page 5: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

5

Memory-Mapped I/O: demerits

• cached IO registers can be disastrous

• complex bus architectures– case (b) is more difficult for MM IO

Page 6: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

6

Direct Memory Access (DMA)

• physical or virtual address?

Page 7: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

7

Goals of I/O Software (1)• Device independence

– programs can access any I/O device – without specifying device in advance

· (floppy, hard drive, or CD-ROM)

• Uniform naming– name of a file or device a string or an integer– not depending on which machine

• Error handling– handle as close to the hardware as possible

• synchronous vs asynchronous• buffered or not

Page 8: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

8

Goals of I/O Software (2)

• Synchronous vs. asynchronous transfers– blocked transfers vs. interrupt-driven

• Buffering– data coming off a device cannot be stored in final

destination

• Sharable vs. dedicated devices– disks are sharable

– tape drives would not be

Page 9: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

9

Programmed I/O

copy_from_user(buffer, p, count) /* p is the kernel buffer */for(i=0; i<count; i++) {

while(*printer_status_register != READY); /* polling */*printer_data_register = p[i];

}

Page 10: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

10

Interrupt-Driven I/O

• syscall ends up with calling the scheduler (a)• the device raises an interrupt when it is ready• the interrupt is handled like (b)

printer

io request

interrupt

Page 11: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

11

I/O Using DMA

• syscall (a) and interrupt handler (b)

Page 12: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

12

I/O Software Layers

Layers of the I/O Software System

Page 13: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

13

Interrupt Handlers (1)1. Save regs not already saved by interrupt hardware

2. Set up context(MMU) for interrupt service procedure

3. Set up stack for interrupt service procedure

4. Ack interrupt controller, reenable interrupts

5. Copy registers from where saved

6. Run service procedure

7. Set up MMU context for process to run next

8. Load new process' registers

9. Start running the new process

top half

bottom half

interrupt handler

Page 14: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

14

Device Drivers device driver

Page 15: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

15

Device Drivers in User Space• Advantages

– all user level utilities can be used

• libraries, debugger

– an error affects only the driver, not the whole kernel

– easy installation (dynamic and static)

• Disadvantages– interrupts are not available

– direct memory is not possible

– slow (user/kernel switching)

– usually not reentrant

Page 16: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

16

Device-Independent I/O Software (1)

Functions of the device-independent I/O software

Uniform interfacing for device drivers

Buffering

Error reporting

Allocating and releasing dedicate devices

Providing a device-independent block size

io software

Page 17: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

17

Device-Independent I/O Software (2)

• Standard interface eases development of device driver

• naming like a file eases protection

Page 18: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

18

Input Buffering

(a) Unbuffered input: process one char at a time(b) Buffering in user space: buffer may be paged out(c) Buffering in the kernel followed by copying to user space:

buffer may not has been copied yet(d) Double buffering in the kernel

Page 19: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

19

Copy Operations Due to Buffering

Networking may involve many copies

Page 20: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

20

Review

Layers of the I/O system and the main functions of each layer

Page 21: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

21

Disk Hardware (1)model Baracuda ATA II cheetah 73capacity30GB 73GBplates # 3 12heads # 6 24RPM 7200 10025sector size 512B samesector/track 63 463track/in 21368 18145seek timeread 8.2 ms 5.85mswrite 9.5ms 6.35mstrack to track(r) 1.2ms 0.6mstrack to track(w) 1.9ms 0.9ms

Page 22: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

22

Disk Hardware (2)

• Physical geometry of a disk with two zones• A possible virtual geometry for this disk

Page 23: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

23

RAID

mirroring

• spread byte or word• disks should be synchronized• Hamming code

• no redundancy• same as SLED for a single sector request

Page 24: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

24

Disk Hardware (4)

• same as RAID-2• parity instead of Hamming• deals with single failure

Page 25: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

25

Disk Formatting

• cylinder skew hides track-to-track seek latency

Page 26: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

26

Disk Interleaving

• no interleaving• accessing consecutive sectors

1. move a sector to buffer2. copy buffer to memory3. move next sector….

•cannot utilized contiguous allocation

• single/double interleaving• better buffer entire track instead of a sector

Page 27: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

27

Disk Arm Scheduling Algorithms (1)

• Time required to read or write a disk block determined by 3 factors

1. Seek time

2. Rotational delay

3. Actual transfer time

• Seek time dominates

• Error checking is done by controllers

Page 28: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

28

Error Handling

• A disk track with a bad sector• Substituting a spare for the bad sector• Shifting all the sectors to bypass the bad one

Page 29: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

29

Stable Storage

• stable storage– writes correct value or leaves the disk intact

• write to mirrored disks– write to disk 1 and verify– do the same to disk 2

• non-volatile RAM speeds up this operation

Page 30: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

30

RS-232 Terminal Hardware

• An RS-232 terminal communicates with computer 1 bit at a time• Called a serial line – bits go out in series, 1 bit at a time• names: /dev/ttyx, COM1 and COM2 ports• Computer and terminal are completely independent

Page 31: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

31

• Central buffer pool• Dedicated buffer for each terminal

Input Software (1)

Page 32: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

32

Display Hardware (1)

Memory-mapped displays• driver writes directly into display's video RAM

Parallel port

Page 33: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

33

Input Software

• Keyboard driver delivers a number– driver converts to characters– uses a ASCII table

• Exceptions, adaptations needed for other languages– many OS provide for loadable keymaps or code

pages

Page 34: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

34

X Windows (1)

Clients and servers in the M.I.T. X Window System

Page 35: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

35

The SLIM Network Terminal (1)

The architecture of the SLIM terminal system

Page 36: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

36

The SLIM Network Terminal (2)

Messages used in the SLIM protocol from the server to the terminals

Page 37: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

37

Power Management (1)

Power consumption of various parts of a laptop computer

Page 38: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

38

Power management (2)

The use of zones for backlighting the display

Page 39: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

39

Power Management (3)

• Running at full clock speed• Cutting voltage by two

– cuts clock speed by two,

– cuts power by four

Page 40: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

40

Power Management (4)

• Telling the programs to use less energy– may mean poorer user experience

• Examples– change from color output to black and white– speech recognition reduces vocabulary– less resolution or detail in an image

Page 41: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

41

AutoRAID• Problems with RAID

– difficult to configure

• requires detailed knowledge of disks and workload

• too many parameters to set

– difficult to change the configuration

– difficult to add disks

– RAID 5 preserve an extra disk to cope with a disk failure (hot spare)

• we don’t know if this disk works since it is not used in normal operation

Page 42: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

42

AutoRAID• The solutions

– Offer a hierarchy of levels

– store active data in mirrored disks and store inactive data in level 5 arrays

– depending the activity, data are moved across this hierarchy

– the active set must be

• small to be fitted into the mirrored disk

• be unchanged for a long time to prevent frequent data movement

Page 43: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

43

Hierarchy Implementation• manually by the system administrator

– error-prone

– cannot adapt to rapidly changing access patterns

– requires highly skilled person

– difficult to add new disks

• file system– best place since it is aware of access patterns for each file and it is a

software

– not in customer’s hand

• array controller (behind scsi controller)– devoid of the knowledge of access patterns

– make the array look like a normal disk

Page 44: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

44

AutoRAID Features• Mapping: maps host block address to physical location

• Mirroring and RAID 5– use mirroring until run short of disk space,

– if space is needed, store some data as RAID 5

– keep data in RAID 1 be at least 10% of all data

– transfer data by the frequency of accesses

• automatic and done in idle time

• online disk upgrade

• dual controllers

• active use of hot spares– when a disk fails, some data in the level 1 are moved to level 5 to

make a room for reconstruction

Page 45: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

45

Hardware Configuration

Page 46: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

46

Data Layout

– LUN = a number of PEX

– RB is visible to clients

Page 47: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

47

Data Layout(2)

Page 48: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

48

Mapping Tables

Page 49: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

49

Migration• from level 5 to level 1 (from inactive to active)

– when RB is written

• from RAID 1 to RAID 5– in background

– if the data has not been changed for a long time

– if space is needed in Mirror

Page 50: Joonwon Lee joon@kaist.ac.kr IO and RAID. 2 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks

50

Review• shows a perfect research and development

– hardware development in parallel with the simulator

– an accurate simulator makes it possible to calibrate the design decision before they committed to making a product

• Comparison with CLARiiON and JBOD(Just Bunch of Disks)– Microbenchmark results do not give much intuition

• Would be nice to show what happens when AutoRAID degrades to the mirrored mode

• Not much why, mostly what

• Does not really tell us much about the statistical significance