diff options
Diffstat (limited to 'bio.c')
-rw-r--r-- | bio.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -24,6 +24,7 @@ #include "defs.h" #include "param.h" #include "spinlock.h" +#include "fs.h" #include "buf.h" struct { @@ -55,20 +56,20 @@ binit(void) } } -// Look through buffer cache for sector on device dev. +// Look through buffer cache for block on device dev. // If not found, allocate a buffer. // In either case, return B_BUSY buffer. static struct buf* -bget(uint dev, uint sector) +bget(uint dev, uint blockno) { struct buf *b; acquire(&bcache.lock); loop: - // Is the sector already cached? + // Is the block already cached? for(b = bcache.head.next; b != &bcache.head; b = b->next){ - if(b->dev == dev && b->sector == sector){ + if(b->dev == dev && b->blockno == blockno){ if(!(b->flags & B_BUSY)){ b->flags |= B_BUSY; release(&bcache.lock); @@ -85,7 +86,7 @@ bget(uint dev, uint sector) for(b = bcache.head.prev; b != &bcache.head; b = b->prev){ if((b->flags & B_BUSY) == 0 && (b->flags & B_DIRTY) == 0){ b->dev = dev; - b->sector = sector; + b->blockno = blockno; b->flags = B_BUSY; release(&bcache.lock); return b; @@ -94,15 +95,16 @@ bget(uint dev, uint sector) panic("bget: no buffers"); } -// Return a B_BUSY buf with the contents of the indicated disk sector. +// Return a B_BUSY buf with the contents of the indicated block. struct buf* -bread(uint dev, uint sector) +bread(uint dev, uint blockno) { struct buf *b; - b = bget(dev, sector); - if(!(b->flags & B_VALID)) + b = bget(dev, blockno); + if(!(b->flags & B_VALID)) { iderw(b); + } return b; } |