Secondary Storage Devices: Magnetic Disks Optical Disks Floppy Disks Magnetic Tapes
1 Outline File Systems Implementation How disks work How to organize data (files) on disks Data...
-
date post
21-Dec-2015 -
Category
Documents
-
view
217 -
download
0
Transcript of 1 Outline File Systems Implementation How disks work How to organize data (files) on disks Data...
1
Outline
File Systems Implementation How disks work How to organize data (files) on
disks Data structures Placement of files on disk
2
Disk Surface Layout
Tracks: concentric rings on disk bits laid out serially on tracks
Tracks split into sectors or blocks Minimum unit of transfer from disk
3
Disk Pack: Multiple Disks
Disks organized in disk pack = stack of platters
Use both sides of platters
Two read-write heads at end of each arm
Cylinders:
4
Cost of Disk Operations
Latency: time to initiate disk transfer Seek time: time to position head
over correct cylinder Rotational time: time for correct
sector to rotate under disk head Bandwidth: rate of I/O transfer of
sectors once initiated
5
Outline
File Systems Implementation How disks work How to organize data (files) on disks
Data structures Placement of files on disk
6
File Organization on Disk
File system maps file blocks to disk location (file 0, block 0) = (platter 0, cylinder 0,
sector 0) Key performance issues:
Support sequential and random access What data structure is best for
maintaining file location information? How do we lay out files on the disk?
7
File System Design Goals
Most systems fit following profile: Most files are small Most disk space taken up by large
files I/O operations target both small &
large Per-file cost must be low, but large
files must also have good performance
8
On-Disk Data Structures
File descriptor/handle: (name, location on disk, attributes) Must be stored on disks just like files
Create file: Adds file descriptor to directory
that contains file Delete file
Find directory containing file Remove file descriptor from
directory
9
Types of File Organization on Disk
Contiguous files Linked files Indexed files
Multilevel indexed files
10
Contiguous Allocation
Operating system maintains ordered list of free disk blocks
OS allocates contiguous chunk of free blocks when it creates a file File descriptor: store start location
& size
11
Contiguous Allocation:Pros & Cons
Advantages Simple Efficient to support which type of
access? Disadvantages
File size change? Fragmentation? Inefficient to support which type of
access? Examples: IBM OS/360, write-only
disks, early PCs
12
Linked Files Maintain list of all free sectors/blocks File descriptor: keep pointer to first sector/block In each sector, keep pointer to next sector
13
Linked Files: Pros & Cons
Advantages Fragmentation? File size changes? Efficient to support which type of access?
Disadvantages: Inefficient to support which type of
access? Number of seeks? Waste space than contiguous allocation?
Examples: MS-DOS
14
Indexed Files
User or OS declares maximum length of file created
OS allocates array of block pointers for all blocks when it creates file But allocates blocks only
on demand OS fills pointers as it
allocates blocks
15
Indexed Files: Pros & Cons
Advantages Sequential & random access: easy
Disadvantages Sets maximum file size Waste more space than linked list Lots of seeks (data not contiguous)
16
Multilevel Indexed Files in UNIX Each file descriptor
contains 14 block pointers First 12 pointers point to
data blocks 13th pointer:
2nd-level/indirect blocks Points to block of 1024
pointers to 1024 more data blocks
14th pointer: 3rd-level blocks
Points to block of 1024 pointers to indirect blocks
Used in BSD UNIX 4.3
17
Multilevel Indexed Files:Pros & Cons
Advantages Simple to implement Supports incremental file growth Small files?
Disadvantages Indirect access: inefficient for random
access to very large files Lots of seeks (data not contiguous)
18
Free-Space Management: Bitmaps
Need free-space list to keep track of which disk blocks are free Akin to free-list for main memory
One approach: bitmap/bitvector One bit per block on disk Bit = 1 , block is free Special hardware to find 1st bit with
value of 1 in a word Marking block free very simple
19
Free-Space Management
Problems: Space: Bitmap has big RAM footprint
80GB disk, 512 byte sectors = ? Mb Performance: Slow if most of disk is in
use Alternative: linked list
Link together free blocks Head of list – cached in kernel memory Each block contains next pointer Efficiency?