Operating Systems
Jinghui Zhong (钟竞辉)Office:B3-515Email :[email protected]
Jinghui Zhong (钟竞辉)Office:B3-515Email :[email protected]
2
File System Backup
Backups are made to handle: recover from disaster or stupidity.Considerations of backupsEntire or part of the file systemIncremental dumps: dump only files that have changed CompressionBackup an active file systemSecurity
3
File System Backup
Two strategies for dumping a disk:① Physical dump: starts at block 0 to the last one.
Advantages: simple and fastDisadvantages: backup everything
② Logical dump: starts at one or more specified directories and recursively dumps all files and directories found that have changed since some given base date.
4
File System Backup
A file system to be dumped (squares are directories, circles are files,shaded items are modified since last dump, each directory & file labeled by i-
node number
File that hasnot changed
5
File System Backup
Bit maps used by the logical dumping algorithm (After 4 phases, the dump is complete)
6
Most OS have a utility program, called a file system checker, to test the consistency of a file system.
E.g., fsck in UNIX, sfc in Windows
Two types of consistency checks can be made: (a) block consistency(b) file consistency
File System Consistency
7
Block consistency:① Build two tables with a counter per block, initially set to
0 , The counters in the first table keep track of number of times each block is present in a file. The counters of the second table record the number of times in free list,
② Then, the program reads all the i-nodes and uses the i-nodes to build a list of all blocks used in the files (incrementing file counter as each block is read).
③ Check free list or bit map to find all blocks not in use (increment free list counter for each block in free list).
File System Consistency
8
File System Consistency
File system states(a) consistent(b) missing block – add it to the free list(c) duplicate block in free list – rebuild the free list(d) duplicate data block – copy the block to a free block
(c) (d)
9
For checking directories – keep a list of counters per file starting at the root directory, recursively inspect each directory. For each file, increment the counter for the files i-nodeCompare computed value with link count stored in each i-node. i-node link count > computed value = number of directory
entries.Even if all files are removed, the i-node link count > 0. So the i-node will not be removed.Solution : set i-node link count = value computed i-node link count < computed value
The i-node may be freed even when there is another directory points to itdirectory will be pointing to unused i-node
solution : set inode link count = computed value
File System Consistency
10
File System PerformanceA block cache or buffer cache is a collection of blocks that logically belong on the disk, but are kept in memory to improve performance.All of the previous paging replacement algorithms can be used to determine which block should be written when a new block is needed and the cache is full.
11
File System Performance
Periodically, all data block should be written out (e.g. write works all day). UNIX - system call sync forces modified blocks out to the disk immediately. e.g. update runs in background during sync every 30 secondsMS-DOS - write-through cache => all modified blocks are written immediately.
e.g. write a 1K block one character at a timeUNIX collect them togetherMS-DOS 1 at a time
12
File System Performance
Reading a block needs one access for the i-node and one for the block. Save i-node access time.
(a) I-nodes placed at the start of the disk(b) Disk divided into cylinder groups, each with its own blocks and i-nodes.
13
The MS-DOS File System
The MS-DOS directory entry
Many digital cameras and MP3 players use it.Use a fixed-size 32 byte directory entry.
14
Maximum partition for different block sizesThe empty boxes represent forbidden combinations
The MS-DOS File System
15
The UNIX V7 File System
A UNIX V7 directory entry
16
A UNIX i-node
The UNIX V7 File System
17
The UNIX V7 File System
The steps in looking up /usr/ast/mbox
18
Check Points① Please describe the two strategies for dumping a disk.
② Please describe the two types of consistency checks .
③ Please describe two methods to increase file-system
performance.
19
Check Points