summaryrefslogtreecommitdiff
path: root/log.c
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2011-10-11 06:41:37 -0400
committerRobert Morris <[email protected]>2011-10-11 06:41:37 -0400
commita5fbfe418abd9bdb876407a73b479cdc39046e9a (patch)
tree9686a62d46f03753dfdcf8564053921a6ead031a /log.c
parentd73dd097a529bc9d13f514ae6884c4d96a0fffa8 (diff)
downloadxv6-labs-a5fbfe418abd9bdb876407a73b479cdc39046e9a.tar.gz
xv6-labs-a5fbfe418abd9bdb876407a73b479cdc39046e9a.tar.bz2
xv6-labs-a5fbfe418abd9bdb876407a73b479cdc39046e9a.zip
clarify some FS comments
Diffstat (limited to 'log.c')
-rw-r--r--log.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/log.c b/log.c
index 832732c..5b827de 100644
--- a/log.c
+++ b/log.c
@@ -42,7 +42,7 @@ struct log {
struct spinlock lock;
int start;
int size;
- int intrans;
+ int busy; // a transaction is active
int dev;
struct logheader lh;
};
@@ -75,7 +75,7 @@ install_trans(void)
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
+ bwrite(dbuf); // write dst to disk
brelse(lbuf);
brelse(dbuf);
}
@@ -95,7 +95,9 @@ read_head(void)
brelse(buf);
}
-// Write in-memory log header to disk, committing log entries till head
+// Write in-memory log header to disk.
+// This is the true point at which the
+// current transaction commits.
static void
write_head(void)
{
@@ -123,10 +125,10 @@ void
begin_trans(void)
{
acquire(&log.lock);
- while (log.intrans) {
+ while (log.busy) {
sleep(&log, &log.lock);
}
- log.intrans = 1;
+ log.busy = 1;
release(&log.lock);
}
@@ -134,14 +136,14 @@ void
commit_trans(void)
{
if (log.lh.n > 0) {
- write_head(); // Causes all blocks till log.head to be commited
- install_trans(); // Install all the transactions till head
+ write_head(); // Write header to disk -- the real commit
+ install_trans(); // Now install writes to home locations
log.lh.n = 0;
- write_head(); // Reclaim log
+ write_head(); // Erase the transaction from the log
}
acquire(&log.lock);
- log.intrans = 0;
+ log.busy = 0;
wakeup(&log);
release(&log.lock);
}
@@ -161,7 +163,7 @@ log_write(struct buf *b)
if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1)
panic("too big a transaction");
- if (!log.intrans)
+ if (!log.busy)
panic("write outside of trans");
for (i = 0; i < log.lh.n; i++) {