diff options
| author | Robert Morris <rtm@csail.mit.edu> | 2020-10-04 13:29:04 -0400 | 
|---|---|---|
| committer | Robert Morris <rtm@csail.mit.edu> | 2020-10-04 13:29:04 -0400 | 
| commit | da002a48fbbf69a0d965755d9f6b66817e8a15a5 (patch) | |
| tree | 7367831972021c4e3215e03cc3f508234b4e34ea | |
| parent | 792d60e91224bc15ce41aaff2560a82b63fdf06f (diff) | |
| download | xv6-labs-da002a48fbbf69a0d965755d9f6b66817e8a15a5.tar.gz xv6-labs-da002a48fbbf69a0d965755d9f6b66817e8a15a5.tar.bz2 xv6-labs-da002a48fbbf69a0d965755d9f6b66817e8a15a5.zip | |
don't unpin if recovering -- the resulting negative refcnt suppresses next unpin
| -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    } | 
