MIT6.828_HW11_xv6 log
First, you’ll artificially create a crash which illustrates why logging is needed. Second, you’ll remove one inefficiency in the xv6 logging system.
1.1. Creating a Problem
xv6日志的要点是使所有可能产生崩溃的文件系统操作都是原子的。 例如,文件创建涉及向目录添加新条目以及将新文件的inode标记为使用中。 如果没有日志,则在重新启动后,在一个之后但在另一个之前发生的崩溃将使文件系统处于不正确的状态。
First, replace commit() in log.c with this code:
#include "mmu.h"
#include "proc.h"
void
commit(void)
{
int pid = myproc()->pid;
if (log.lh.n > 0) {
write_log();
write_head();
if(pid > 1) // AAA
log.lh.block[0] = 0; // BBB
// Copy committed blocks from log to their home location
install_trans();
if(pid > 1) // AAA
panic("commit mimicking crash"); // CCC
log.lh.n = 0;
write_head();
}
}
</