From b63d3506e9fbe7db1cd117db746fb58b7712ab4f Mon Sep 17 00:00:00 2001 From: Frans Kaashoek Date: Thu, 5 Nov 2020 11:09:21 -0500 Subject: [PATCH] Be principled: acquire lock first --- kernel/log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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;