summaryrefslogtreecommitdiff
path: root/log.c
diff options
context:
space:
mode:
authorAustin Clements <[email protected]>2011-08-15 14:11:22 -0400
committerAustin Clements <[email protected]>2011-08-15 14:12:35 -0400
commit843eecfcd0c23f2b9466e5c3289c1819950ccb47 (patch)
tree732cac1121352c5aa76469ec74cc4999579c2ac3 /log.c
parent7f1718ca33fb333435b05cd9a0541e6e3b9b7249 (diff)
downloadxv6-labs-843eecfcd0c23f2b9466e5c3289c1819950ccb47.tar.gz
xv6-labs-843eecfcd0c23f2b9466e5c3289c1819950ccb47.tar.bz2
xv6-labs-843eecfcd0c23f2b9466e5c3289c1819950ccb47.zip
Only commit log to disk if something was written in to it.
Without this, every write to the console results in log writes.
Diffstat (limited to 'log.c')
-rw-r--r--log.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/log.c b/log.c
index e9a16c5..6b5c329 100644
--- a/log.c
+++ b/log.c
@@ -143,11 +143,13 @@ begin_trans(void)
void
commit_trans(void)
{
- write_head(); // This 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
-
+ 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
+ log.lh.n = 0;
+ write_head(); // Reclaim log
+ }
+
acquire(&log.lock);
log.intrans = 0;
wakeup(&log);