4.4.persistence-fs-impl
4.4.persistence-fs-impl
Endadul Hoque
Acknowledgement
– Access methods
• How does it map the calls made by a process as open(),
read(), write(), etc.?
• Which structures are read during the execution of a particular
system call?
Overall Organization
• Let’s develop the overall on-disk organization of the file
system data structure.
• vsfs (very simple file system)
• Divide the disk into blocks.
– Block size is 4 KB.
– The blocks are addressed from 0 to N -1.
0 7 8 15 16 23 24 31
32 39 40 47 48 55 56 63
Data region in file system
• Reserve data region to store user data (i.e., file content)
Data Region
D D D D D D D D D D D D D D D D D D D D D D D D
0 7 8 15 16 23 24 31
Data Region
D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D
32 39 40 47 48 55 56 63
– File system has to track which data blocks comprise a file and its
metadata (the size of the file, its owner, etc.)
• It uses an inode (index node) structure
How can we store
the inodes in the file
system?
Inode table in file system
• Reserve some space for inode table
– This holds an array of on-disk inodes.
– Ex) inode table: 5 blocks (from 3 to 7) and inode size : 256 bytes
• Each 4-KB block can hold 16 inodes.
• The filesystem supports total 80 inodes. (maximum number of files)
I I I I I D D D D D D D D D D D D D D D D D D D D D D D D
0 7 8 15 16 23 24 31
Data Region
D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D
32 39 40 47 48 55 56 63
How does the file system
keep track whether
inodes or data blocks are
free or allocated?
Allocation structures
• These structures are to track whether inodes or data
blocks are free or allocated.
• Use bitmap, each bit indicates free(0) or in-use(1)
– data bitmap: for data region
– inode bitmap: for inode table
Inodes Data Region
i d I I I I I D D D D D D D D D D D D D D D D D D D D D D D D
0 7 8 15 16 23 24 31
Data Region
D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D
32 39 40 47 48 55 56 63
Superblock
• Super block (S) contains the information for particular
file system
– Ex) The number of inodes, starting location of inode table. etc
Inodes Data Region
S i d I I I I I D D D D D D D D D D D D D D D D D D D D D D D D
0 7 8 15 16 23 24 31
Data Region
D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D
32 39 40 47 48 55 56 63
4 5 6 7 20 21 22 23 36 37 38 39 52 53 54 55 68 69 70 71
Super i-bmap d-bmap 8 9 10 11 24 25 26 27 40 41 42 43 56 57 58 59 72 73 74 75
12 13 14 15 28 29 30 31 44 45 46 47 60 61 62 63 76 77 78 79
4 5 6 7 20 21 22 23 36 37 38 39 52 53 54 55 68 69 70 71
Super i-bmap d-bmap 8 9 10 11 24 25 26 27 40 41 42 43 56 57 58 59 72 73 74 75
12 13 14 15 28 29 30 31 44 45 46 47 60 61 62 63 76 77 78 79
open( read
/foo/bar, read
O_RDONL read
Y) read
read
read() read
read
write
read() read
read
write
read() read
read
write
open( read
/foo/bar, read
O_RDONL read
Y) read
read
read() read
read
write
read() read
read
write
read() read
read
write
create ( read
/foo/bar) read
read
read
[Assume, read
/foo/bar write
doesn’t write
exist in read
/foo/] write
write
write() read
read
write write
write
write() read
read
write write
write
write() read
read write
write
write