-log-file system
Download
Report
Transcript -log-file system
Aneela Tabassum
1
Basic Problem in UFSS
Most file systems now have large memory caches
(buffers) to hold recently-accessed blocks.
Most reads are thus satisfied from the buffer cache.
Most traffic is to write traffic on the disk.
We need to make writes go faster.
But disk performance is limited according to disk
head movement.
2
Motivation for Log-FS
Technology:
Disk is the bottleneck.
Faster CPU.
no faster disk.
Faster memory (thus cache).
Larger disks.
Workloads:
Random access to the disk.
Small reads and writes.
3
Disk is the Bottleneck (1)
cylinder k
surface 0
surface 1
surface 2
surface 3
surface 4
surface 5
platter 0
platter 1
Track
spindle
spindle
spindle
spindle
platter 2
spindle
,
The read/write
head attach with
the end of arm .
the arm can
position the
read/write head
over any track.
4
Bottleneck
5
LFS: Basic Idea
LFS is use as alternative of UFS.
A log is a data structure that is written only at the
head.
If the disk were managed as a log, there would be
effectively no head seeks
The “file” is always added to sequentially
New data and metadata (inodes, directories) are
accumulated in the buffer cache.
This would greatly increase disk throughput.
6
Issues (1): Retrieving Information
from Logs
(since data and metadata are written together,
sequentially)
inode map records current location of each inode
the inode map itself is divided into blocks written on the disk
a fixed region on each disk keeps track of all inode map
blocks
inode map small enough to fit into the memory
7
Structure File System
Disk
Write sequentially : never overwrite data
8
Unix Structure File System
Disk
File 1
File 2
Update
File 1
Write sequentially : never overwrite data
9
Log-Structure File System
Disk
Block 0 Block 1 Block 2
10
Log-Structure File System
Disk
Node A
Block 0 Block 1 Block 2
11
Where does the meta-data go?
Disk
Node A
Block 0 Block 1 Block 2
12
Log-Structure File System
Disk
Node A
Block 0 Block 1 Block 2
Block 3 Block 4 Block 6 ……
13
Log-Structure File System
Disk
Node A
Block 0 Block 1 Block 2
Block 3 Block 4 Block 5 Block 6
Disk, continued
Node B
Block 7
14
Updating a file
Disk
Node A
Block 0 Block 1 Block 2
Block 3 Block 4 Block 5 Block 6
Disk, continued
Node B
Block 7
Block 1
update
15
Updating a file
Disk
Node A
Block 0 Block 1 Block 2
Block 3 Block 4 Block 5 Block 6
Disk, continued
Node A’
Node B
Block 7
Block 1
update
16
Updating a file
Disk
Node A
Block 0 Block 1 Block 2
Block 3 Block 4 Block 5 Block 6
Disk, continued
Node A’
Node B
Block 7
Block 1
update
17
Updating a file
Disk
Node A
Block 0 Block 1 Block 2
Block 3 Block 4 Block 5 Block 6
Disk, continued
Node A`
Node B
Block 7
Block 1
update
18
Updating a file
Disk
Node A
Block 0 Block 1 Block 2
Block 3 Block 4 Block 5 Block 6
Disk, continued
Node A`
Node B
Block 7
Block 1
update
19
Imap
2
1
0
Pointer to most recant version of node
Disk
Node A
Block 0 Block 1 Block 2
Block 3 Block 4 Block 5 Block 6
Disk, continued
Node A`
Node B
Block 7
Block 1
update
20
Imap
2
1
0
Pointer to most recant version of node
Disk
Node A
Block 0 Block 1 Block 2
Block 3 Block 4 Block 5 Block 6
Disk, continued
Node A`
Node B
Block 7
Block 1
update
21
Once the disk fill up with lot of old junk
Disk
Node A
Block 0 Block 1 Block 2
Block 3 Block 4 Block 5 Block 6
Disk, continued
Imap
Block 5
Block 8 update
Node B’
Imap
Node A`
Node B
Block 7
Block 1
update
….
22
Issues(2): Manage Free Space
Through a combination of threading and copying
○ fixed-size extents called segments (512 KB or 1 MB)
○ identify live data from segments
○ copy live data in a compacted form and clean the remaining
segments
23
Garbage collection in LSFS
Disk
Node A
Block 0 Block 1 Block 2
Block 3 Block 4 Block 5 Block 6
Disk, continued
Imap
Block 5
Block 8 update
Node B’
Imap
Node A`
Node B
Block 7
Block 1
update
….
24
Dead memory or garbage collection
Disk
Node A
Block 0 Block 1 Block 2
Block 3 Block 4 Block 5 Block 6
Disk, continued
Imap
Block 5
Block 8 update
Node B’
Imap
Node A`
Node B
Block 7
Block 1
update
….
25
Dead memory or garbage collection
segment
Node A
Block 0 Block 1 Block 2
Block 3 Block 4 Block 5 Block 6
Disk, continued
Imap
Block 5
Block 8 update
Node B’
Imap
Node A`
Node B
Block 7
Block 1
update
….
26
Disk Defragmentation
Block 6
Imap
Block 5
Block 8 update
Node B’
Imap
Node A`
Node B
Block 7
Block 1
update
….
Disk
Block 0 Block 2 Block 3 Block 4
27
LFS Data Structures
inodes: as in Unix, inodes contain physical block
pointers for files.
inode map: a table indicating where each inode is
on the disk.
inode map blocks are written as part of the segment.
segment summary: info on every block in a
segment.
segment usage table: info on the amount of “live”
data in a block.
28
LFS vs. UFS
file2
file1
inode
directory
dir1
dir2
Unix File
System
inode map
dir2
dir1
Log
file1
data
file2
Log-Structured
File System
Blocks written to
create two 1-block
files: dir1/file1 and
dir2/file2, in UFS and
LFS
29
Group Work: File System
Operations
Open an existing file
2. Create a new file
3. Remove a file
4. Rename a file
5. Modify an existing file
6. Modify a directory
1.
30
THE END
31