File System Implementation: Sunu Wibirama
File System Implementation: Sunu Wibirama
Sunu Wibirama
Thursday, December 16, 2010
Outline
File-System Structure
File-System Implementation
Directory Implementation
Allocation Methods
Free-Space Management
Discussion
11.
11.
11.
11.
11.
11.
11.
11.
11.
An allocation method refers to how disk blocks are allocated for files:
Contiguous allocation
Linked allocation
Indexed allocation
11.
11.
11.
pointer (4 bytes)
11.
Disadvantages:
No random access (only sequential access)
Space required for pointers (0.78 percent of the disk is being used for pointers, rather
than for information) ~> solution, uses clusters (unit of blocks)
Reliability, pointer damage will cause unlinked blocks in a file.
11.
To do random access:
1. The disk head move to the start of volume
to read the FAT
2. Find the location of the desired block
3. Move to the location of the block itself
11.
11.
11.
1st-level
index block
2nd-level
index block
file
11.
11.
0 1 2 n-1
0 ⇒ block[i] free
bit[i] =
1 ⇒ block[i] occupied
{(number of bits per word) *(number of 0-value words)} +offset of first 1 bit
11.
Grouping
Storing the address of n blocks in the first free
block.
n-1 blocks are actually free blocks but the last
block contains the addresses of another n free
blocks.
Counting
Keep the address of the first free block and n of
free contiguous blocks that follow the first block.
Each entry in free-space list consists of disk
address and a count
11.
http://en.wikipedia.org/wiki/Defragmentation
Thursday, December 16, 2010
Why Linux rarely needs
defragmentation tools?
I have hello.txt
I have hello.txt
I have hello.txt
I want to change
? hello.txt, dude...
2nd approach
If the first approach requires huge read and write operation, then
the most possible approach is the second one. That’s why FAT
suffers from large fragmentation
Thursday, December 16, 2010
What About Linux?
Initial condition
Add bye.txt
Change hello.txt