summaryrefslogtreecommitdiff
path: root/bio.c
diff options
context:
space:
mode:
authorrtm <rtm>2007-08-24 19:32:36 +0000
committerrtm <rtm>2007-08-24 19:32:36 +0000
commit902b13f5d6bab19f7a218acc655421cdb63f4313 (patch)
tree7c54f9fa80eeeb87f72fc7a58e3c5bc4fad70af8 /bio.c
parent2bc72bdd29d605f7106204cc8293f9e5be4113e9 (diff)
downloadxv6-labs-902b13f5d6bab19f7a218acc655421cdb63f4313.tar.gz
xv6-labs-902b13f5d6bab19f7a218acc655421cdb63f4313.tar.bz2
xv6-labs-902b13f5d6bab19f7a218acc655421cdb63f4313.zip
simplify ide queuing
nits in comments
Diffstat (limited to 'bio.c')
-rw-r--r--bio.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/bio.c b/bio.c
index c819b6b..7f5d158 100644
--- a/bio.c
+++ b/bio.c
@@ -4,15 +4,14 @@
// holding cached copies of disk block contents.
// Each buf has two state bits B_BUSY and B_VALID.
// If B_BUSY is set, it means that some code is currently
-// editing buf, so other code is not allowed to look at it.
+// modifying buf, so other code is not allowed to look at it.
// To wait for a buffer that is B_BUSY, sleep on buf.
// (See bget below.)
//
-// If B_VALID is set, it means that the memory contents
-// have been initialized by reading them off the disk.
-// (Conversely, if B_VALID is not set, the memory contents
+// If B_VALID is set, it means that the sector in b->data is
+// the same as on the disk. If B_VALID is not set, the contents
// of buf must be initialized, often by calling bread,
-// before being used.)
+// before being used.
//
// After making changes to a buf's memory, call bwrite to flush
// the changes out to disk, to keep the disk and memory copies
@@ -79,7 +78,6 @@ bget(uint dev, uint sector)
goto loop;
}
b->flags |= B_BUSY;
- // b->flags &= ~B_VALID; // Force reread from disk
release(&buf_table_lock);
return b;
}
@@ -98,7 +96,8 @@ bget(uint dev, uint sector)
panic("bget: no buffers");
}
-// Read buf's contents from disk.
+// Return a B_BUSY buf with the contents of the indicated
+// disk sector.
struct buf*
bread(uint dev, uint sector)
{
@@ -108,7 +107,8 @@ bread(uint dev, uint sector)
if(b->flags & B_VALID)
return b;
- ide_rw(dev & 0xff, sector, b->data, 1, 1);
+ b->flags &= ~B_WRITE;
+ ide_rw(b);
b->flags |= B_VALID;
return b;
@@ -121,7 +121,8 @@ bwrite(struct buf *b)
{
if((b->flags & B_BUSY) == 0)
panic("bwrite");
- ide_rw(b->dev & 0xff, b->sector, b->data, 1, 0);
+ b->flags |= B_WRITE;
+ ide_rw(b);
b->flags |= B_VALID;
}