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