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); } }