From 0655445ba911b59378c57e0c58258c7d6c171880 Mon Sep 17 00:00:00 2001 From: rsc Date: Tue, 14 Aug 2007 19:42:14 +0000 Subject: [PATCH] cleanup loop --- bio.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/bio.c b/bio.c index 4ead39f..feeda5f 100644 --- a/bio.c +++ b/bio.c @@ -71,20 +71,18 @@ bget(uint dev, uint sector) loop: // 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)) && - b->dev == dev && b->sector == sector) - break; - - if(b != &bufhead){ - if(b->flags & B_BUSY){ - sleep(buf, &buf_table_lock); - goto loop; + b->dev == dev && b->sector == sector){ + if(b->flags & B_BUSY){ + sleep(buf, &buf_table_lock); + goto loop; + } + b->flags |= B_BUSY; + // 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.