Session 5 6 Revision
Session 5 6 Revision
Session 5 6 Revision
Session-5 & 6
Revision
Session Plan
Design and Implementation of log.c
(10 mnts)
• https://github.com/mit-pdos/xv6-public/blob/
master/log.c
Logging –Crash Recovery in File Systems
• Crash Recovery is one of the issue in File
Systems.
• This issue arises when many file system
operations involve multiple writes to the disk.
• This may result in a crash after a subset of the
writes may leave the on-disk file system in an
inconsistent state.
• This problem can be solved using log based
recovery.
• Log is a sequence of records of write activities
and maintains a history of all update activities.
How xv6 solves the crash problem?
• Xv6 solves the problem of crashes during file system
operations with a simple form of logging.
• An xv6 system call does not directly write the on-
disk file system data structures.
• Instead, it places a description of all the disk writes it
wishes to make in a log on the disk.
• Once the system call has logged all of its writes, it
writes a special commit record to the disk indicating
that the log contains a complete operation.
• Then the system call copies the writes to the on-disk
file system data structures.
• After those writes have completed, the system call
erases the log on disk.
Log based crash recovery
• If the system should crash and reboot, the file
system code recovers from the crash as follows,
before running any processes.
• If the log is marked as containing a complete
operation, then the recovery code copies the
writes to where they belong in the on-disk file
system.
• If the log is not marked as containing a
complete operation, the recovery code ignores
the log.
• The recovery code finishes by erasing the log.
log.c-Sheet No.47 from xv6 Code Manual
Discussion of ALMs
https://www.cse.iitb.ac.in/~mythili/os/ps/xv6/p
s-xv6-file.pdf
Session-5 ALM-1