diff options
author | msmith <msmith@FreeBSD.org> | 1998-11-02 23:28:11 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 1998-11-02 23:28:11 +0000 |
commit | 7ff854a690d0b1907eb91aa8563be0d65545984d (patch) | |
tree | 4b5368009c1e11ed85475d58f2f379071897c96a /sys/boot/i386 | |
parent | 459dfe3332e2fac684dc0f5ce1af023d9101c0b0 (diff) | |
download | FreeBSD-src-7ff854a690d0b1907eb91aa8563be0d65545984d.zip FreeBSD-src-7ff854a690d0b1907eb91aa8563be0d65545984d.tar.gz |
Implement a simple LRU block cache. By default this is initialised to 16k,
and will bypass transfers for more than 8k. Blocks are invalidated after
2 seconds, so removable media should not confuse the cache.
The 8k threshold is a compromise; all UFS transfers performed by
libstand are 8k or less, so large file reads thrash the cache.
However many filesystem metadata operations are also performed using
8k blocks, so using a lower threshold gives poor performance.
Those of you with an eye for cache algorithms are welcome to tell me
how badly this one sucks; you can start with the 'bcachestats' command
which will print the contents of the cache and access statistics.
Diffstat (limited to 'sys/boot/i386')
-rw-r--r-- | sys/boot/i386/libi386/biosdisk.c | 13 | ||||
-rw-r--r-- | sys/boot/i386/loader/main.c | 7 |
2 files changed, 18 insertions, 2 deletions
diff --git a/sys/boot/i386/libi386/biosdisk.c b/sys/boot/i386/libi386/biosdisk.c index b4c7769..502d3be 100644 --- a/sys/boot/i386/libi386/biosdisk.c +++ b/sys/boot/i386/libi386/biosdisk.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: biosdisk.c,v 1.15 1998/10/30 07:15:52 luoqi Exp $ + * $Id: biosdisk.c,v 1.16 1998/10/31 02:53:11 msmith Exp $ */ /* @@ -103,6 +103,7 @@ static int bd_int13probe(struct bdinfo *bd); static int bd_init(void); static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize); +static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize); static int bd_open(struct open_file *f, ...); static int bd_close(struct open_file *f); static void bd_print(int verbose); @@ -495,6 +496,16 @@ bd_closedisk(struct open_disk *od) static int bd_strategy(void *devdata, int rw, daddr_t dblk, size_t size, void *buf, size_t *rsize) { + struct bcache_devdata bcd; + + bcd.dv_strategy = bd_realstrategy; + bcd.dv_devdata = devdata; + return(bcache_strategy(&bcd, rw, dblk, size, buf, rsize)); +} + +static int +bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size, void *buf, size_t *rsize) +{ struct open_disk *od = (struct open_disk *)(((struct i386_devdesc *)devdata)->d_kind.biosdisk.data); int blks; #ifdef BD_SUPPORT_FRAGS diff --git a/sys/boot/i386/loader/main.c b/sys/boot/i386/loader/main.c index 2e0ed80..dfd1bff 100644 --- a/sys/boot/i386/loader/main.c +++ b/sys/boot/i386/loader/main.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: main.c,v 1.12 1998/10/21 20:10:33 msmith Exp $ + * $Id: main.c,v 1.13 1998/10/22 20:23:58 msmith Exp $ */ /* @@ -98,6 +98,11 @@ main(void) cons_probe(); /* + * Initialise the block cache + */ + bcache_init(32, 512); /* 16k cache XXX tune this */ + + /* * March through the device switch probing for things. */ for (i = 0; devsw[i] != NULL; i++) |