commit
函数中write_log();
已经把数据从缓冲区拷贝到log中,所以我们可以直接在install_trans
函数里将log中的数据写入磁盘。
static void
install_trans(void)
{
int tail;
for (tail = 0; tail < log.lh.n; tail++) {
// struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block
struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst
// memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst
bwrite(dbuf); // write dst to disk
// brelse(lbuf);
brelse(dbuf);
}
}