Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent...

16
Disk Access

Transcript of Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent...

Page 1: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

Disk Access

Page 2: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

DISK STRUCTURE

• Sector: Smallest unit of data transfer from/to disk; 512B

• 2/4/8 adjacent sectors transferred together: Blocks

• Read/write heads can be positioned over 1 cylinder at a time

Page 3: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

DISK ACCESS

• Seek time: Mechanically moving the R/W head to the correct track ~msec

• Rotation time: Rotate the required sector(s) under the R/W head ~msec

• Transfer time: Actual read/write of the data from/to disk surface

Page 4: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

Interface to the rest of the System

• CPU connected to I/O device: I/O bus• I/O bus addresses for each connected

device: I/O ports• I/O interface converts between I/O bus and

device specific commands: SCSI, ATA/IDE• I/O controller: hardware on the disk drive to

do the actual data transfer. E.g. move the R/W head

Page 5: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

• Each device has I/O ports for a command/ status/ data read and data write register

• OS can write a command (say Write), write the data into the data write register and keep looking at the status register to see when write completes: POLLING

• Or OS can write command and write data and disk can INTERRUPT it when data has been written

• Use DMA to transfer multiple bytes between disk and memory; Interrupt CPU after transferring a block of bytes

Page 6: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

Types of I/O

• Synchronous: Process which requested I/O is put in wait queue. Back to run queue when I/O completes

• Asynchronous: I/O system call returns immediately even without any data having been transferred

Page 7: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

Filesystems

• Present an interface to the disk storage with filenames, protection, organization into directories …

• Major filesystem functions:

1. Map filename to areas on the disk

2. Manage free blocks on the disk

Page 8: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

Disk Allocation

• Each file has some ‘header’ information, including disk block information

• Contiguous allocation: header has starting block and number of blocks

• Scattered allocation: header has to have each block number

Page 9: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

Unix/Linux Implementation

• File header = inode

• Each partition is divided into block groups (BG), usually groups of adjacent cylinders on disk

• BGs reduce fragmentation; kernel tries to keep data blocks of a file in a single BG

Page 10: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

Block Groups

• Data Block Bitmap: Free space management

• Inode Table: List of inodes in the BG

• Inodes provide mapping between file offset (file block number) and disk block number (logical block number)

Page 11: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

Inodes

File Blk No.

0

1

Logical Blk No.

Single Indirect

Double Indirect

Triple Indirect

Direct Direct Direct

Disk Blocks

Page 12: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

Speeding up things

• Read-Ahead: Read adjacent data ahead of time; store in cache

• Data block allocation: Allocate block near previously allocated blocks/ same BG as inode/ other BGs

• Pre-allocation: Allocate more (upto 8 adjacent) blocks than requested

Page 13: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

RAID

• Redundant Array of Independent Disks

• Advantages

1. Reliability: Redundant copies/ Error correction information

2. Performance: Parallel/ Striped transfer

Page 14: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

RAID levels

• RAID 0 Non-redundant striping

+ Striping improves I/O transfer rate

- No reliability improvement

• RAID 1 Disk mirroring

+ High reliability

+ Parallel reads

- High cost

Page 15: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

RAID levels

• RAID 2 Memory style Error Correction Code; Bit-level striping

+ Reliability at a possibly lower cost- Parity calculation overhead for writes• RAID 3/RAID 4 Byte/Block interleaved parity

+ Reliability with only 1 extra disk for parity

- Parity calculation for each write; overload parity disk

Page 16: Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.

RAID levels

• RAID 5/ RAID 6 Distributed parity

+ Parity load distributed

+ RAID 6 can recover from multi-disk failures

• Nested RAID

• RAID 0+1

• RAID 1+0