don't unpin if recovering -- the resulting negative refcnt suppresses next unpin
This commit is contained in:
parent
aeaf610c67
commit
548ffc97e1
|
@ -66,7 +66,7 @@ initlog(int dev, struct superblock *sb)
|
||||||
|
|
||||||
// Copy committed blocks from log to their home location
|
// Copy committed blocks from log to their home location
|
||||||
static void
|
static void
|
||||||
install_trans(void)
|
install_trans(int recovering)
|
||||||
{
|
{
|
||||||
int tail;
|
int tail;
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ install_trans(void)
|
||||||
struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst
|
struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst
|
||||||
memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst
|
memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst
|
||||||
bwrite(dbuf); // write dst to disk
|
bwrite(dbuf); // write dst to disk
|
||||||
|
if(recovering == 0)
|
||||||
bunpin(dbuf);
|
bunpin(dbuf);
|
||||||
brelse(lbuf);
|
brelse(lbuf);
|
||||||
brelse(dbuf);
|
brelse(dbuf);
|
||||||
|
@ -116,7 +117,7 @@ static void
|
||||||
recover_from_log(void)
|
recover_from_log(void)
|
||||||
{
|
{
|
||||||
read_head();
|
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;
|
log.lh.n = 0;
|
||||||
write_head(); // clear the log
|
write_head(); // clear the log
|
||||||
}
|
}
|
||||||
|
@ -195,7 +196,7 @@ commit()
|
||||||
if (log.lh.n > 0) {
|
if (log.lh.n > 0) {
|
||||||
write_log(); // Write modified blocks from cache to log
|
write_log(); // Write modified blocks from cache to log
|
||||||
write_head(); // Write header to disk -- the real commit
|
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;
|
log.lh.n = 0;
|
||||||
write_head(); // Erase the transaction from the log
|
write_head(); // Erase the transaction from the log
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue