cleanup loop
This commit is contained in:
parent
2186f88c21
commit
0655445ba9
1 changed files with 10 additions and 12 deletions
22
bio.c
22
bio.c
|
@ -71,20 +71,18 @@ bget(uint dev, uint sector)
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
// Try for cached block.
|
// Try for cached block.
|
||||||
for(b = bufhead.next; b != &bufhead; b = b->next)
|
for(b = bufhead.next; b != &bufhead; b = b->next){
|
||||||
if((b->flags & (B_BUSY|B_VALID)) &&
|
if((b->flags & (B_BUSY|B_VALID)) &&
|
||||||
b->dev == dev && b->sector == sector)
|
b->dev == dev && b->sector == sector){
|
||||||
break;
|
if(b->flags & B_BUSY){
|
||||||
|
sleep(buf, &buf_table_lock);
|
||||||
if(b != &bufhead){
|
goto loop;
|
||||||
if(b->flags & B_BUSY){
|
}
|
||||||
sleep(buf, &buf_table_lock);
|
b->flags |= B_BUSY;
|
||||||
goto loop;
|
// b->flags &= ~B_VALID; // Force reread from disk
|
||||||
|
release(&buf_table_lock);
|
||||||
|
return b;
|
||||||
}
|
}
|
||||||
b->flags |= B_BUSY;
|
|
||||||
// b->flags &= ~B_VALID; // Force reread from disk
|
|
||||||
release(&buf_table_lock);
|
|
||||||
return b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate fresh block.
|
// Allocate fresh block.
|
||||||
|
|
Loading…
Reference in a new issue