File-System Structure
File-System Structure
File-System Structure
File structure
IO control
Directory Implementation
Has a large effect on the file system performance
A) Linear list of file names with pointer to the data blocks.
simplest to program
time-consuming to execute as require a linear search
E.g., to create a new file name we must search the directory to
make sure that no such file exist
When we open the file we must search the linear structure
Many OS implement a software cache for the most
frequently/recently accessed directory information
Allocation Methods
Many files are stored on the same disk;
one main problem is to allocate space on disk to the files
1) Contiguous allocation
Allocation for a file is contiguous on disk
2) Linked allocation
Blocks are linked together on disk so can be anywhere
3) Indexed allocation
Blocks are mapped with a table that contains pointers to
disk blocks (similar to page table)
Contiguous Allocation
Extent-Based Systems
Many newer file systems (e.g. Veritas File System) use a
modified contiguous allocation scheme.
Extent-based file systems allocate disk blocks in extents.
Linked Allocation
Each file is a linked list of disk blocks: blocks may be
scattered anywhere on the disk.
block
pointer
Linked Allocation
Indexed Allocation
Linked allocation solves external fragmentation but cannot
support direct access (FAT helps in that)
Indexed allocation solves the direct access problem by
Logical view.
index table
outer-index
index table
file
Free-Space Management
Space represented with Bit vector (n blocks)
0 1
n-1
bit[i] =
block[i] free
block[i] occupied
Need to protect:
Pointer to free list
Bit map
Must be kept on disk
Copy in memory and disk may differ (coherence issue).
Cannot allow for block[i] to have a situation where bit[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
Performance
Page Cache
A page cache caches pages rather than disk blocks
using virtual memory techniques.
Memory-mapped I/O uses a page cache.
Routine I/O through the file system uses the buffer (disk)
cache.
This leads to the following figure.