Pertemuan 22 Implementasi Sistem File Matakuliah : T0316/sistem Operasi

advertisement
Matakuliah
Tahun
Versi/Revisi
: T0316/sistem Operasi
: 2005
:5
Pertemuan 22
Implementasi Sistem File
1
Learning Outcomes
Pada akhir pertemuan ini, diharapkan mahasiswa
akan mampu :
• menunjukkan implementasi sistem file (C3)
2
Outline Materi
•
•
•
•
•
•
Contiguous Allocation
Linked list allocation
Linked list allocation using Table
I-Nodes
Implementasi directory
Disk space management
3
File System Implementation
A possible file system layout
4
Implementing Files (1)
(a) Contiguous
allocation of
disk space
for 7 files
(b) State of the
disk after
files D and E
have been
removed
+ simplicity: only remember disk address & number of
blocks in the file
read performance
– fragmentation
5
Implementing Files (2)
Storing a file as a linked
list of disk blocks
+ minimal fragmentation
– random access is slow
6
Implementing Files (3)
+ minimal fragmentation,
random access is easier
– entire table must be in
memory all the time
Linked list allocation using a file allocation table (FAT) in RAM
7
Implementing Files (4)
+ in memory when the file is open
– disk address may insufficient
 use the last address as the
address of more disk block
addresses
An example i-node
8
Implementing Directories
The directory entries provide information
needed to find the disk blocks
The information may be:
• the disk address of the entire file (contiguous)
• the number of first block (linked list)
•The number of I-node
9
Implementing Directories (1)
(a) A simple directory (for MS-DOS/Windows)
fixed size entries
disk addresses and attributes in directory entry
(b) Directory in which each entry just refers to an i-node (for
UNIX)
10
Implementing Directories (2)
• Two ways of handling long file names in directory
– (a) In-line
– (b) In a heap
11
Shared Files (1)
– consistency problem in
update 
disk blocks are listed in
the data structure/I-node
instead of directories
OR
use symbolic linking
which contains the file’s
path name
File system containing a shared file
12
Shared Files (2)
(a) Situation prior to linking
(b) After the link is created
(c)After the original owner removes the file
13
Disk Space Management (1)
Block size
• Dark line (left hand scale) gives data rate of a disk
• Dotted line (right hand scale) gives disk space efficiency
• All files 2KB
14
Disk Space Management (2)
(a) Storing the free list on a linked list
(b) A bit map
15
Disk Space Management (3)
Quotas for keeping track of each user’s disk use
16
File System Reliability
• Backups
• Strategies for dumping disk to a tape
– Physical dump
• From block 0 until last
– Logical dump
• Dump all files and directories changed since given
base date
17
File System Reliability (1)
-- Logical dump
File that has
not changed
• A file system to be dumped
– squares are directories, circles are files
– shaded items, modified since last dump
– each directory & file labeled by i-node number
18
File System Reliability (2)
Bit maps used by the logical dumping algorithm
(a) Dump changed files and all directories, then
(b) Dump changed files and directories above them
(c) + (d)  (b)
19
File System Reliability (3)
• File system states
(a) consistent
(b) missing block
(c) duplicate block in free list
(d) duplicate data block
20
File System Performance (1)
The block cache data structures
21
File System Performance (2)
• I-nodes placed at the start of the disk
• Disk divided into cylinder groups
– each with its own blocks and i-nodes
22
Log-Structured File Systems
• With CPUs faster, memory larger
– disk caches can also be larger
– increasing number of read requests can come from
cache
– thus, most disk accesses will be writes
• LFS Strategy structures entire disk as a log
– have all writes initially buffered in memory
– periodically write these to the end of the disk log
– when file opened, locate i-node, then find blocks
23
Download