diff options
author | Robert Morris <[email protected]> | 2011-10-11 06:41:37 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2011-10-11 06:41:37 -0400 |
commit | a5fbfe418abd9bdb876407a73b479cdc39046e9a (patch) | |
tree | 9686a62d46f03753dfdcf8564053921a6ead031a /bio.c | |
parent | d73dd097a529bc9d13f514ae6884c4d96a0fffa8 (diff) | |
download | xv6-labs-a5fbfe418abd9bdb876407a73b479cdc39046e9a.tar.gz xv6-labs-a5fbfe418abd9bdb876407a73b479cdc39046e9a.tar.bz2 xv6-labs-a5fbfe418abd9bdb876407a73b479cdc39046e9a.zip |
clarify some FS comments
Diffstat (limited to 'bio.c')
-rw-r--r-- | bio.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -7,7 +7,7 @@ // // Interface: // * To get a buffer for a particular disk block, call bread. -// * After changing buffer data, call bwrite to flush it to disk. +// * After changing buffer data, call bwrite to write it to disk. // * When done with the buffer, call brelse. // * Do not use the buffer after calling brelse. // * Only one process at a time can use a buffer, @@ -16,8 +16,7 @@ // The implementation uses three state flags internally: // * B_BUSY: the block has been returned from bread // and has not been passed back to brelse. -// * B_VALID: the buffer data has been initialized -// with the associated disk block contents. +// * B_VALID: the buffer data has been read from the disk. // * B_DIRTY: the buffer data has been modified // and needs to be written to disk. @@ -58,7 +57,7 @@ binit(void) // Look through buffer cache for sector on device dev. // If not found, allocate fresh block. -// In either case, return locked buffer. +// In either case, return B_BUSY buffer. static struct buf* bget(uint dev, uint sector) { @@ -67,7 +66,7 @@ bget(uint dev, uint sector) acquire(&bcache.lock); loop: - // Try for cached block. + // Is the sector already cached? for(b = bcache.head.next; b != &bcache.head; b = b->next){ if(b->dev == dev && b->sector == sector){ if(!(b->flags & B_BUSY)){ @@ -80,7 +79,7 @@ bget(uint dev, uint sector) } } - // Allocate fresh block. + // Not cached; recycle some existing buffer. for(b = bcache.head.prev; b != &bcache.head; b = b->prev){ if((b->flags & B_BUSY) == 0){ b->dev = dev; @@ -105,7 +104,7 @@ bread(uint dev, uint sector) return b; } -// Write b's contents to disk. Must be locked. +// Write b's contents to disk. Must be B_BUSY. void bwrite(struct buf *b) { @@ -115,7 +114,8 @@ bwrite(struct buf *b) iderw(b); } -// Release the buffer b. +// Release a B_BUSY buffer. +// Move to the head of the MRU list. void brelse(struct buf *b) { |