summaryrefslogtreecommitdiffstats
path: root/sys/boot/common/bcache.c
diff options
context:
space:
mode:
authordcs <dcs@FreeBSD.org>2000-03-15 01:56:12 +0000
committerdcs <dcs@FreeBSD.org>2000-03-15 01:56:12 +0000
commit24a0d62243b159dc7531b0f0c3064575f8f0fe94 (patch)
tree0632b481771b815533ad4a873d3bb1162bc8f3f8 /sys/boot/common/bcache.c
parent0edaa7aeae6d265b624f2d3ce4945a29c4e13d7d (diff)
downloadFreeBSD-src-24a0d62243b159dc7531b0f0c3064575f8f0fe94.zip
FreeBSD-src-24a0d62243b159dc7531b0f0c3064575f8f0fe94.tar.gz
bcache_strategy() now receives an unit number, and keep track of what
was the last unit number received. If it changes, it flushes the cache. Add bcache_flash(). The actual fix is sligthly different from the one in the PR. PR: 17098 Submitted by: John Hood <jhood@sitaranetworks.com>
Diffstat (limited to 'sys/boot/common/bcache.c')
-rw-r--r--sys/boot/common/bcache.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/sys/boot/common/bcache.c b/sys/boot/common/bcache.c
index c52854e..efdcbe0 100644
--- a/sys/boot/common/bcache.c
+++ b/sys/boot/common/bcache.c
@@ -60,6 +60,7 @@ static bitstr_t *bcache_miss;
static int bcache_nblks;
static int bcache_blksize;
static int bcache_hits, bcache_misses, bcache_ops, bcache_bypasses;
+static int bcache_flushes;
static int bcache_bcount;
static void bcache_insert(caddr_t buf, daddr_t blkno);
@@ -71,8 +72,6 @@ static int bcache_lookup(caddr_t buf, daddr_t blkno);
int
bcache_init(int nblks, size_t bsize)
{
- int i;
-
/* discard any old contents */
if (bcache_data != NULL) {
free(bcache_data);
@@ -97,13 +96,24 @@ bcache_init(int nblks, size_t bsize)
return(ENOMEM);
}
- /* Invalidate the cache */
+ return(0);
+}
+
+/*
+ * Flush the cache
+ */
+void
+bcache_flush()
+{
+ int i;
+
+ bcache_flushes++;
+
+ /* Flush the cache */
for (i = 0; i < bcache_nblks; i++) {
bcache_ctl[i].bc_count = -1;
bcache_ctl[i].bc_blkno = -1;
}
-
- return(0);
}
/*
@@ -115,8 +125,9 @@ bcache_init(int nblks, size_t bsize)
* directly to the disk. XXX tune this.
*/
int
-bcache_strategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf, size_t *rsize)
+bcache_strategy(void *devdata, int unit, int rw, daddr_t blk, size_t size, void *buf, size_t *rsize)
{
+ static int bcache_unit = -1;
struct bcache_devdata *dd = (struct bcache_devdata *)devdata;
int nblk, p_size;
daddr_t p_blk;
@@ -124,7 +135,12 @@ bcache_strategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf, size
int i, j, result;
bcache_ops++;
-
+
+ if(bcache_unit != unit) {
+ bcache_flush();
+ bcache_unit = unit;
+ }
+
/* bypass large requests, or when the cache is inactive */
if ((bcache_data == NULL) || ((size * 2 / bcache_blksize) > bcache_nblks)) {
DEBUG("bypass %d from %d", size / bcache_blksize, blk);
@@ -256,7 +272,7 @@ command_bcache(int argc, char *argv[])
if (((i + 1) % 4) == 0)
printf("\n");
}
- printf("\n%d ops %d bypasses %d hits %d misses\n", bcache_ops, bcache_bypasses, bcache_hits, bcache_misses);
+ printf("\n%d ops %d bypasses %d hits %d misses %d flushes\n", bcache_ops, bcache_bypasses, bcache_hits, bcache_misses, bcache_flushes);
return(CMD_OK);
}
OpenPOWER on IntegriCloud