CS124 Lec 24
CS124 Lec 24
Directory Entry: A 3 11
File Allocation 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Table: 4 10 13 -1 14 15 11
3
index
3
A 2 4
10
Location of
Index Block 13
14
15
11
-1
Contents of -1
Index Block …
5
Indexing Approaches
• Option 1: a linked sequence of index blocks
• Each index block has an array of file-block pointers
• Last pointer in index block is either “end of index” value,
or a pointer to the next index block
• Good for smaller files
• Example: storage blocks of 512B; 32-bit index entries
• 512 bytes / 4 bytes = maximum of 128 entries
• Index block might store 100 or more entries (extra space
for storing file metadata)
• 100 entries per index block × 512 byte blocks = ~50KB file size for
a single index block
• Usually want to use virtual page size as block size instead
• Max of 1024 entries per 4KiB page
• If index entries refer to 4KiB blocks, a single index block can be
used for up to 4MB files before requiring a second index block
8
File Deletion
• File deletion is a generally straightforward operation
• Specific implementation details depend heavily home
on the file system format
• General procedure: user1 user2
• Remove the directory entry referencing the file
A B C D
• If the file system contains no other hard-links
to the file, record that all of the file’s blocks are
A C
now available for other files to use
• The file system must record what blocks are available for
use when files are created or extended
• Often called a free-space list, although many different
ways to record this information
• Some file systems already have a way of doing this, e.g.
FAT formats simply mark clusters as unused in the table
17
old old
F2.2 F3.1 F3.2 F3.3 F2.2 F3.1 F3.2 F3.3
old
F1.1' F2.1' F1.3' F1.2'' F1.1' F2.1' F1.3' F1.2''
23
old old
F2.2 F3.1 F3.2 F3.3 F2.2 F3.1 F3.2 F3.3
old old
Erase! F3.4 F1.2' F3.1' F3.4'
old old
F1.1' F2.1' F1.3' F1.2'' F1.1' F2.1' F1.3' F1.2''
24
old
F1.1' F2.1' F1.3' F1.2''
25
Remaining Schedule…
• No class on Friday, March 7!
• Last class on Monday, March 10
• Topic: Journaling in filesystems