Upload
hung-le-thanh
View
219
Download
0
Embed Size (px)
Citation preview
7/31/2019 10 Implement File System
1/30
Chapter 11:
Implementing File Systems
7/31/2019 10 Implement File System
2/30
7/31/2019 10 Implement File System
3/30
11.3 Silberschatz, Galvin and Gagne 2005Operating System Principles
Objectives
To describe the details of implementing local file systems anddirectory structures
To describe the implementation of remote file systems
To discuss block allocation and free-block algorithms and trade-offs
7/31/2019 10 Implement File System
4/30
11.4 Silberschatz, Galvin and Gagne 2005Operating System Principles
File-System Structure
File structure
Logical storage unit
Collection of related information
File system resides on secondary storage (disks)
File system organized into layers
File control block storage structure consisting of informationabout a file
7/31/2019 10 Implement File System
5/30
11.5 Silberschatz, Galvin and Gagne 2005Operating System Principles
A Typical File Control Block
7/31/2019 10 Implement File System
6/30
11.6 Silberschatz, Galvin and Gagne 2005Operating System Principles
In-Memory File System Structures
The following figure illustrates the necessary file system structuresprovided by the operating systems.
Figure 12-3(a) refers to opening a file.
Figure 12-3(b) refers to reading a file.
7/31/2019 10 Implement File System
7/3011.7 Silberschatz, Galvin and Gagne 2005Operating System Principles
In-Memory File System Structures
7/31/2019 10 Implement File System
8/3011.8 Silberschatz, Galvin and Gagne 2005Operating System Principles
Virtual File Systems
Virtual File Systems (VFS) provide an object-oriented way ofimplementing file systems.
VFS allows the same system call interface (the API) to be used fordifferent types of file systems.
The API is to the VFS interface, rather than any specific type of filesystem.
7/31/2019 10 Implement File System
9/3011.9 Silberschatz, Galvin and Gagne 2005Operating System Principles
Schematic View of Virtual File System
7/31/2019 10 Implement File System
10/3011.10 Silberschatz, Galvin and Gagne 2005Operating System Principles
Directory Implementation
Linear list of file names with pointer to the data blocks.
simple to program
time-consuming to execute
Hash Table linear list with hash data structure.
decreases directory search time
collisions situations where two file names hash to the samelocation
fixed size
7/31/2019 10 Implement File System
11/3011.11 Silberschatz, Galvin and Gagne 2005Operating System Principles
Allocation Methods
An allocation method refers to how disk blocks are allocated forfiles:
Contiguous allocation
Linked allocation
Indexed allocation
7/31/2019 10 Implement File System
12/3011.12 Silberschatz, Galvin and Gagne 2005Operating System Principles
Contiguous Allocation
Each file occupies a set of contiguous blocks on the disk
Simple only starting location (block #) and length (numberof blocks) are required
Random access
Wasteful of space (dynamic storage-allocation problem)
Files cannot grow
7/31/2019 10 Implement File System
13/3011.13 Silberschatz, Galvin and Gagne 2005Operating System Principles
Contiguous Allocation of Disk Space
7/31/2019 10 Implement File System
14/3011.14 Silberschatz, Galvin and Gagne 2005Operating System Principles
Extent-Based Systems
Many newer file systems (I.e. Veritas File System) use a modifiedcontiguous allocation scheme
Extent-based file systems allocate disk blocks in extents
An extent is a contiguous block of disks Extents are allocated for file allocation
A file consists of one or more extents.
7/31/2019 10 Implement File System
15/30
7/31/2019 10 Implement File System
16/3011.16 Silberschatz, Galvin and Gagne 2005Operating System Principles
File-Allocation Table
7/31/2019 10 Implement File System
17/3011.17 Silberschatz, Galvin and Gagne 2005Operating System Principles
Indexed Allocation
Brings all pointers together into the index block.
Logical view.
index table
7/31/2019 10 Implement File System
18/3011.18 Silberschatz, Galvin and Gagne 2005Operating System Principles
Example of Indexed Allocation
7/31/2019 10 Implement File System
19/3011.19 Silberschatz, Galvin and Gagne 2005Operating System Principles
Indexed Allocation Mapping (Cont.)
outer-index
index table file
7/31/2019 10 Implement File System
20/3011.20 Silberschatz, Galvin and Gagne 2005Operating System Principles
Combined Scheme: UNIX (4K bytes per block)
7/31/2019 10 Implement File System
21/3011.21 Silberschatz, Galvin and Gagne 2005Operating System Principles
Free-Space Management
Bit vector (nblocks)
0 1 2 n-1
bit[i] =
0 block[i] free
1 block[i] occupied
Block number calculation
(number of bits per word) *
(number of 0-value words) +offset of first 1 bit
7/31/2019 10 Implement File System
22/3011.22 Silberschatz, Galvin and Gagne 2005Operating System Principles
Free-Space Management (Cont.)
Bit map requires extra space
Example:
block size = 212 bytes
disk size = 230 bytes (1 gigabyte)
n= 230/212 = 218 bits (or 32K bytes)
Easy to get contiguous files
Linked list (free list)
Cannot get contiguous space easily
No waste of space
Grouping Counting
7/31/2019 10 Implement File System
23/30
11.23 Silberschatz, Galvin and Gagne 2005Operating System Principles
Free-Space Management (Cont.)
Need to protect:
Pointer to free list
Bit map
Must be kept on disk
Copy in memory and disk may differ
Cannot allow for block[i] to have a situation wherebit[i] = 1 in memory and bit[i] = 0 on disk
Solution:
Set bit[i] = 1 in disk
Allocate block[i]
Set bit[i] = 1 in memory
7/31/2019 10 Implement File System
24/30
11.24 Silberschatz, Galvin and Gagne 2005Operating System Principles
Directory Implementation
Linear list of file names with pointer to the data blocks
simple to program
time-consuming to execute
Hash Table linear list with hash data structure
decreases directory search time
collisions situations where two file names hash to the samelocation
fixed size
7/31/2019 10 Implement File System
25/30
11.25 Silberschatz, Galvin and Gagne 2005Operating System Principles
Linked Free Space List on Disk
7/31/2019 10 Implement File System
26/30
11.26 Silberschatz, Galvin and Gagne 2005Operating System Principles
FAT (12, 16, 32) systemFile Allocation Table
26
File1 File1
File2
File1
File3File2
File2 empty empty
3
4EOF
68
EOFEOF0000
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
2 3 4
5 6 7
8 9 10Cluster
Boot sectorFile allocation
table 2 (duplicate)File allocation
table 1Root directory Other directories and all files
Name Property Start
File 1
2File 2 5File 3 7
FAT12: 32MB
FAT16: 4GB
FAT32: 8TB
7/31/2019 10 Implement File System
27/30
11.27 Silberschatz, Galvin and Gagne 2005Operating System Principles27
NTFS (New Technology File System)
16 exabytes(16 billion GB)
FilenameStandard
information
Security
descriptorData
7/31/2019 10 Implement File System
28/30
11.28 Silberschatz, Galvin and Gagne 2005Operating System Principles28
Unix /Linux file systemI-node
boot block super block I-node files and directories
Single indirect:256KB
Double indirect:
256*256 = 65 MB
Triple indirect:256*256*256 =16GB
7/31/2019 10 Implement File System
29/30
11.29 Silberschatz, Galvin and Gagne 2005Operating System Principles29
UNIX V7 file system
7/31/2019 10 Implement File System
30/30
End of Chapter 11