Chapter 5 Part 2 Secondary Storage MGT File MGT in Popular Oss Eighth Edition
Chapter 5 Part 2 Secondary Storage MGT File MGT in Popular Oss Eighth Edition
Systems:
Internals Chapter 5 Part 2
and Design
Principles
Secondary Storage Mgt.
File Mgt. in Popular OSs
Eighth Edition
By William Stallings
File Allocation
§ On secondary storage, a file consists of a collection of blocks
§ The approach taken for file allocation may influence the approach
taken for free space management
n Items to be considered:
1) contiguity of space increases performance, especially for
Retrieve_Next operations, and greatly for transactions
running in a transaction-oriented operating system
2) having a large number of small portions increases the size of
tables needed to manage the allocation information
3) having fixed-size portions simplifies the reallocation of space
4) having variable-size or small fixed-size portions minimizes
waste of unused storage due to overallocation
Alternatives
Two major alternatives:
15 16 17 18 19
File C
20 21 22 23 24
File E
25 26 27 28 29
File D
30 31 32 33 34
20 21 22 23 24
25 26 27 28 29
30 31 32 33 34
10 11 12 13 14
15 16 17 18 19
20 21 22 23 24
25 26 27 28 29
30 31 32 33 34
10 11 12 13 14
15 16 17 18 19
20 21 22 23 24
25 26 27 28 29
30 31 32 33 34
10 11 12 13 14
15 16 17 18 19
1
20 21 22 23 24 8
3
25 26 27 28 29 14
28
30 31 32 33 34
10 11 12 13 14
15 16 17 18 19
Start Block Length
20 21 22 23 24 1 3
28 4
25 26 27 28 29 14 1
30 31 32 33 34
Advantages:
• works well with any file
allocation method
• it is as small as possible
Chained Free Portions
n The free portions may be chained together by using a pointer and
length value in each free portion
Disadvantages:
• leads to fragmentation
• every time you allocate a block you need to read
the block first to recover the pointer to the new
first free block before writing data to that block
Indexing
n Treats free space as a file and uses an index table as it would for file
allocation
n This approach provides efficient support for all of the file allocation
methods
Free Block List
There are two effective
Depending on the size of
Each block is assigned a techniques for storing a
the disk, either 24 or 32 small part of the free
number sequentially bits will be needed to store
block list in main
a single block number memory:
Directory
• contains a list of file names plus pointers to associated inodes
Special
• contains no data but provides a mechanism to map physical devices to file names
Named pipes
• an interprocess communications facility
Links
• an alternative file name for an existing file
Symbolic links
• a data file that contains the name of the file it is linked to
Inodes
n All types of UNIX files are administered by the OS by means of
inodes
direct(0) Data
Pointers
Data Data
Pointers
direct(12)
triple indirect
Pointers
block count Data
reference count
Pointers Pointers
flags (2)
Data
Pointers
generation number
extended
attribute Pointers
blocks Data
Inode
Direct 12 48K
i1 Name1
i2 Name2
i3 Name3
i4 Name4
File
system Individual File Kernel
Systems space
Buffer cache
Device drivers
Files on secondary
storage maintained
by file system X
n Each row describes a file on this volume, including the MFT itself,
which is treated as a file
Note: Colored rows refer to required file attributes; the other attributes are optional.
I/O Manager
Log the transaction
Log File NTFS Driver Read/write a
Service mirrored or
Read/write
Fault Tolerant striped volume
the file
Flush the Write the Driver
Read/write
log file cache the disk
Disk Driver
Virtual Memory
Manager
(ro)
/system bin
etc
lib
/data (rw)
usr
/cache (rw)