summaryrefslogtreecommitdiff
path: root/kernel/log.c
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2020-11-05 11:09:21 -0500
committerFrans Kaashoek <[email protected]>2020-11-05 19:50:46 -0500
commitb4c2851bb347d5243a4498fdd9e1f0c9a23e6498 (patch)
tree212818e5f08e4bca1675013e3ccae18e1a4974aa /kernel/log.c
parent38084bcea84e79f5fff9ce8c7f91c077fc1eacd3 (diff)
downloadxv6-labs-b4c2851bb347d5243a4498fdd9e1f0c9a23e6498.tar.gz
xv6-labs-b4c2851bb347d5243a4498fdd9e1f0c9a23e6498.tar.bz2
xv6-labs-b4c2851bb347d5243a4498fdd9e1f0c9a23e6498.zip
Be principled: acquire lock first
Diffstat (limited to 'kernel/log.c')
-rw-r--r--kernel/log.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/log.c b/kernel/log.c
index c8af5bd..2c0063a 100644
--- a/kernel/log.c
+++ b/kernel/log.c
@@ -216,12 +216,12 @@ log_write(struct buf *b)
{
int i;
+ acquire(&log.lock);
if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1)
panic("too big a transaction");
if (log.outstanding < 1)
panic("log_write outside of trans");
- acquire(&log.lock);
for (i = 0; i < log.lh.n; i++) {
if (log.lh.block[i] == b->blockno) // log absorbtion
break;