首页 > 技术文章 > MIT6.828 Fall2018 笔记 - Homework 11: xv6 log

zsmumu 2020-05-12 15:14 原文

Homework: xv6 log

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

推荐阅读