summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2020-10-04 13:29:04 -0400
committerFrans Kaashoek <[email protected]>2020-10-05 19:30:27 -0400
commit548ffc97e1befae9e88604e919b4c87fa33f1e9d (patch)
tree7367831972021c4e3215e03cc3f508234b4e34ea
parentaeaf610c671dbf180fa276821aa8fc01b2461aef (diff)
downloadxv6-labs-548ffc97e1befae9e88604e919b4c87fa33f1e9d.tar.gz
xv6-labs-548ffc97e1befae9e88604e919b4c87fa33f1e9d.tar.bz2
xv6-labs-548ffc97e1befae9e88604e919b4c87fa33f1e9d.zip
don't unpin if recovering -- the resulting negative refcnt suppresses next unpin
-rw-r--r--kernel/log.c9
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
}