summaryrefslogtreecommitdiff
path: root/log.c
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2011-08-29 17:18:40 -0400
committerFrans Kaashoek <[email protected]>2011-08-29 17:18:40 -0400
commit1ddfbbb194e3aa668b33469eb547132a7a7f940a (patch)
tree41ad0ae10ef2743c6e9433e711358dede77ce041 /log.c
parent22f7db5336cb20c82eb1ffa45c0ef63825442c95 (diff)
downloadxv6-labs-1ddfbbb194e3aa668b33469eb547132a7a7f940a.tar.gz
xv6-labs-1ddfbbb194e3aa668b33469eb547132a7a7f940a.tar.bz2
xv6-labs-1ddfbbb194e3aa668b33469eb547132a7a7f940a.zip
Revert "Introduce and use sleeplocks instead of BUSY flags"
My changes have a race with re-used bufs and the code doesn't seem to get shorter Keep the changes that fixed ip->off race This reverts commit 3a5fa7ed9020eaf8ab843a16d26db7393b2ec072. Conflicts: defs.h file.c file.h
Diffstat (limited to 'log.c')
-rw-r--r--log.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/log.c b/log.c
index d2dcba7..6b5c329 100644
--- a/log.c
+++ b/log.c
@@ -43,9 +43,9 @@ struct logheader {
struct {
struct spinlock lock;
- struct sleeplock sleeplock;
int start;
int size;
+ int intrans;
int dev;
struct logheader lh;
} log;
@@ -60,7 +60,6 @@ initlog(void)
struct superblock sb;
initlock(&log.lock, "log");
- initsleeplock(&log.sleeplock);
readsb(ROOTDEV, &sb);
log.start = sb.size - sb.nlog;
log.size = sb.nlog;
@@ -134,7 +133,10 @@ void
begin_trans(void)
{
acquire(&log.lock);
- acquire_sleeplock(&log.sleeplock, &log.lock);
+ while (log.intrans) {
+ sleep(&log, &log.lock);
+ }
+ log.intrans = 1;
release(&log.lock);
}
@@ -147,8 +149,10 @@ commit_trans(void)
log.lh.n = 0;
write_head(); // Reclaim log
}
+
acquire(&log.lock);
- release_sleeplock(&log.sleeplock);
+ log.intrans = 0;
+ wakeup(&log);
release(&log.lock);
}
@@ -167,7 +171,7 @@ log_write(struct buf *b)
if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1)
panic("too big a transaction");
- if (!acquired_sleeplock(&log.sleeplock))
+ if (!log.intrans)
panic("write outside of trans");
// cprintf("log_write: %d %d\n", b->sector, log.lh.n);