cleanup loop

This commit is contained in:
rsc 2007-08-14 19:42:14 +00:00
parent 2186f88c21
commit 0655445ba9

8
bio.c
View file

@ -71,12 +71,9 @@ 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 != &bufhead){
if(b->flags & B_BUSY){ if(b->flags & B_BUSY){
sleep(buf, &buf_table_lock); sleep(buf, &buf_table_lock);
goto loop; goto loop;
@ -86,6 +83,7 @@ bget(uint dev, uint sector)
release(&buf_table_lock); release(&buf_table_lock);
return b; return b;
} }
}
// Allocate fresh block. // Allocate fresh block.
for(b = bufhead.prev; b != &bufhead; b = b->prev){ for(b = bufhead.prev; b != &bufhead; b = b->prev){