提交 37eec3b1 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

a bit less contention with dirbench

上级 175e0c2e
...@@ -145,9 +145,7 @@ bread(uint dev, uint sector, int writer) ...@@ -145,9 +145,7 @@ bread(uint dev, uint sector, int writer)
if(!(b->flags & B_VALID)) if(!(b->flags & B_VALID))
iderw(b); iderw(b);
if (writer && !origwriter) { if (writer && !origwriter) {
acquire(&b->lock); __sync_fetch_and_and(&b->flags, ~B_BUSY);
b->flags &= ~B_BUSY;
release(&b->lock);
cv_wakeup(&b->cv); cv_wakeup(&b->cv);
} }
return b; return b;
...@@ -169,11 +167,9 @@ void ...@@ -169,11 +167,9 @@ void
brelse(struct buf *b, int writer) brelse(struct buf *b, int writer)
{ {
if (writer) { if (writer) {
acquire(&b->lock);
if((b->flags & B_BUSY) == 0) if((b->flags & B_BUSY) == 0)
panic("brelse"); panic("brelse");
b->flags &= ~B_BUSY; __sync_fetch_and_and(&b->flags, ~B_BUSY);
release(&b->lock);
cv_wakeup(&b->cv); cv_wakeup(&b->cv);
} }
// rcu_begin_read() happens in bread // rcu_begin_read() happens in bread
......
...@@ -368,6 +368,8 @@ void ...@@ -368,6 +368,8 @@ void
iput(struct inode *ip) iput(struct inode *ip)
{ {
if(__sync_sub_and_fetch(&ip->ref, 1) == 0) { if(__sync_sub_and_fetch(&ip->ref, 1) == 0) {
if (ip->nlink)
return;
acquire(&ip->lock); acquire(&ip->lock);
if (ip->ref == 0 && ip->nlink == 0) { if (ip->ref == 0 && ip->nlink == 0) {
// inode is no longer used: truncate and free inode. // inode is no longer used: truncate and free inode.
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论