Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent...
-
Upload
charleen-goodwin -
Category
Documents
-
view
213 -
download
1
Transcript of Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent...
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 can be positioned over 1 cylinder at a time
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
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
• 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
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
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
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
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
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)
Inodes
File Blk No.
0
1
Logical Blk No.
Single Indirect
Double Indirect
Triple Indirect
Direct Direct Direct
Disk Blocks
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
RAID
• Redundant Array of Independent Disks
• Advantages
1. Reliability: Redundant copies/ Error correction information
2. Performance: Parallel/ Striped transfer
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
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
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