diff options
| -rw-r--r-- | kernel/log.c | 9 | 
1 files changed, 5 insertions, 4 deletions
| diff --git a/kernel/log.c b/kernel/log.c index 5e884bb..c8af5bd 100644 --- a/kernel/log.c +++ b/kernel/log.c @@ -66,7 +66,7 @@ initlog(int dev, struct superblock *sb)  // Copy committed blocks from log to their home location  static void -install_trans(void) +install_trans(int recovering)  {    int tail; @@ -75,7 +75,8 @@ install_trans(void)      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 -    bunpin(dbuf); +    if(recovering == 0) +      bunpin(dbuf);      brelse(lbuf);      brelse(dbuf);    } @@ -116,7 +117,7 @@ static void  recover_from_log(void)  {    read_head(); -  install_trans(); // if committed, copy from log to disk +  install_trans(1); // if committed, copy from log to disk    log.lh.n = 0;    write_head(); // clear the log  } @@ -195,7 +196,7 @@ commit()    if (log.lh.n > 0) {      write_log();     // Write modified blocks from cache to log      write_head();    // Write header to disk -- the real commit -    install_trans(); // Now install writes to home locations +    install_trans(0); // Now install writes to home locations      log.lh.n = 0;      write_head();    // Erase the transaction from the log    } | 
