summaryrefslogtreecommitdiff
path: root/bio.c
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2011-10-11 06:41:37 -0400
committerRobert Morris <[email protected]>2011-10-11 06:41:37 -0400
commita5fbfe418abd9bdb876407a73b479cdc39046e9a (patch)
tree9686a62d46f03753dfdcf8564053921a6ead031a /bio.c
parentd73dd097a529bc9d13f514ae6884c4d96a0fffa8 (diff)
downloadxv6-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.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/bio.c b/bio.c
index 6a3968b..88b0964 100644
--- a/bio.c
+++ b/bio.c
@@ -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)
{