summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2011-10-14 10:23:23 -0400
committerRobert Morris <[email protected]>2011-10-14 10:23:23 -0400
commit12abb1a56164a0d71fb7a76a465c912409f2f60b (patch)
treebc03592160be0e13960a9c106ecf5d48aadbe897
parent38eee5bca75cc16d40101953bc2003bb77d452e7 (diff)
downloadxv6-labs-12abb1a56164a0d71fb7a76a465c912409f2f60b.tar.gz
xv6-labs-12abb1a56164a0d71fb7a76a465c912409f2f60b.tar.bz2
xv6-labs-12abb1a56164a0d71fb7a76a465c912409f2f60b.zip
don't let dirty blocks be evicted from cache!
-rw-r--r--bio.c4
-rw-r--r--file.c8
-rw-r--r--log.c1
-rw-r--r--sysfile.c6
4 files changed, 15 insertions, 4 deletions
diff --git a/bio.c b/bio.c
index 88b0964..de1d0f2 100644
--- a/bio.c
+++ b/bio.c
@@ -79,9 +79,9 @@ bget(uint dev, uint sector)
}
}
- // Not cached; recycle some existing buffer.
+ // Not cached; recycle some non-busy and clean buffer.
for(b = bcache.head.prev; b != &bcache.head; b = b->prev){
- if((b->flags & B_BUSY) == 0){
+ if((b->flags & B_BUSY) == 0 && (b->flags & B_DIRTY) == 0){
b->dev = dev;
b->sector = sector;
b->flags = B_BUSY;
diff --git a/file.c b/file.c
index 3fd2cbe..53c5af2 100644
--- a/file.c
+++ b/file.c
@@ -1,3 +1,7 @@
+//
+// File descriptors
+//
+
#include "types.h"
#include "defs.h"
#include "param.h"
@@ -87,7 +91,7 @@ filestat(struct file *f, struct stat *st)
return -1;
}
-// Read from file f. Addr is kernel address.
+// Read from file f.
int
fileread(struct file *f, char *addr, int n)
{
@@ -108,7 +112,7 @@ fileread(struct file *f, char *addr, int n)
}
//PAGEBREAK!
-// Write to file f. Addr is kernel address.
+// Write to file f.
int
filewrite(struct file *f, char *addr, int n)
{
diff --git a/log.c b/log.c
index 5b827de..1814edc 100644
--- a/log.c
+++ b/log.c
@@ -177,6 +177,7 @@ log_write(struct buf *b)
brelse(lbuf);
if (i == log.lh.n)
log.lh.n++;
+ b->flags |= B_DIRTY; // XXX prevent eviction
}
//PAGEBREAK!
diff --git a/sysfile.c b/sysfile.c
index 9de3d86..e6d08e8 100644
--- a/sysfile.c
+++ b/sysfile.c
@@ -1,3 +1,9 @@
+//
+// File-system system calls.
+// Mostly argument checking, since we don't trust
+// user code, and calls into file.c and fs.c.
+//
+
#include "types.h"
#include "defs.h"
#include "param.h"