don't unpin if recovering -- the resulting negative refcnt suppresses next unpin

This commit is contained in:
Robert Morris 2020-10-04 13:29:04 -04:00
parent 792d60e912
commit da002a48fb

View file

@ -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
}