summaryrefslogtreecommitdiff
path: root/log.c
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2011-09-01 12:03:49 -0400
committerRobert Morris <[email protected]>2011-09-01 12:03:49 -0400
commit62e3b8a92c6f8840cec8a0db13b2bcad10192b4a (patch)
tree6186d2ac5e654ba71f8f45ae9956c560d7251dfc /log.c
parent5a236924444db768813d726ae165d263856d8bff (diff)
parentd0f3efca650eccd5179e045cd07f7d723037defc (diff)
downloadxv6-labs-62e3b8a92c6f8840cec8a0db13b2bcad10192b4a.tar.gz
xv6-labs-62e3b8a92c6f8840cec8a0db13b2bcad10192b4a.tar.bz2
xv6-labs-62e3b8a92c6f8840cec8a0db13b2bcad10192b4a.zip
Merge branch 'master' of git+ssh://amsterdam.csail.mit.edu/home/am0/6.828/xv6
Conflicts: vm.c
Diffstat (limited to 'log.c')
-rw-r--r--log.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/log.c b/log.c
index 6b5c329..ef6c1e7 100644
--- a/log.c
+++ b/log.c
@@ -76,12 +76,11 @@ install_trans(void)
//if (log.lh.n > 0)
// cprintf("install_trans %d\n", log.lh.n);
for (tail = 0; tail < log.lh.n; tail++) {
- // cprintf("put entry %d to disk block %d\n", tail, log.lh.sector[tail]);
- struct buf *lbuf = bread(log.dev, log.start+tail+1); // read i'th block from log
- struct buf *dbuf = bread(log.dev, log.lh.sector[tail]); // read dst block
- memmove(dbuf->data, lbuf->data, BSIZE);
- bwrite(dbuf);
- brelse(lbuf);
+ struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block
+ struct buf *dbuf = bread(log.dev, log.lh.sector[tail]); // read dst
+ memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst
+ bwrite(dbuf); // flush dst to disk
+ brelse(lbuf);
brelse(dbuf);
}
}
@@ -102,7 +101,7 @@ read_head(void)
// cprintf("read_head: %d\n", log.lh.n);
}
-// Write the in-memory log header to disk, committing log entries till head
+// Write in-memory log header to disk, committing log entries till head
static void
write_head(void)
{
@@ -144,10 +143,10 @@ void
commit_trans(void)
{
if (log.lh.n > 0) {
- write_head(); // This causes all blocks till log.head to be commited
- install_trans(); // Install all the transactions till head
+ write_head(); // Causes all blocks till log.head to be commited
+ install_trans(); // Install all the transactions till head
log.lh.n = 0;
- write_head(); // Reclaim log
+ write_head(); // Reclaim log
}
acquire(&log.lock);