提交 3d2dedd4 创建 作者: Cody Cutler's avatar Cody Cutler

fix buf where concurrent fs syscalls race on log entries

上级 41f16c21
...@@ -217,6 +217,7 @@ log_write(struct buf *b) ...@@ -217,6 +217,7 @@ log_write(struct buf *b)
if (log.outstanding < 1) if (log.outstanding < 1)
panic("log_write outside of trans"); panic("log_write outside of trans");
acquire(&log.lock);
for (i = 0; i < log.lh.n; i++) { for (i = 0; i < log.lh.n; i++) {
if (log.lh.sector[i] == b->sector) // log absorbtion if (log.lh.sector[i] == b->sector) // log absorbtion
break; break;
...@@ -225,5 +226,6 @@ log_write(struct buf *b) ...@@ -225,5 +226,6 @@ log_write(struct buf *b)
if (i == log.lh.n) if (i == log.lh.n)
log.lh.n++; log.lh.n++;
b->flags |= B_DIRTY; // prevent eviction b->flags |= B_DIRTY; // prevent eviction
release(&log.lock);
} }
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论