]> Devi Nivas Git - cs3210-lab0.git/commitdiff
fix buf where concurrent fs syscalls race on log entries
authorCody Cutler <ccutler@csail.mit.edu>
Thu, 19 Feb 2015 16:51:47 +0000 (11:51 -0500)
committerCody Cutler <ccutler@csail.mit.edu>
Thu, 19 Feb 2015 16:51:47 +0000 (11:51 -0500)
log.c

diff --git a/log.c b/log.c
index b66074c5cf6e3d29d986886c67dafe818ebb2c6e..f519a8c27f5e8e21a1ef0364a19bc5e141a871fa 100644 (file)
--- a/log.c
+++ b/log.c
@@ -217,6 +217,7 @@ log_write(struct buf *b)
   if (log.outstanding < 1)
     panic("log_write outside of trans");
 
+  acquire(&log.lock);
   for (i = 0; i < log.lh.n; i++) {
     if (log.lh.sector[i] == b->sector)   // log absorbtion
       break;
@@ -225,5 +226,6 @@ log_write(struct buf *b)
   if (i == log.lh.n)
     log.lh.n++;
   b->flags |= B_DIRTY; // prevent eviction
+  release(&log.lock);
 }