diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2012-04-05 09:26:41 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2012-04-05 09:26:41 +0000 |
commit | bff1f2dca7be72c82459d905bdbfdaa51e626e2d (patch) | |
tree | 7b3253cc4a4a0da9926f99ac0ea18a294fff203a /sys | |
parent | c57d49a44f485a5e0ffda5a16c469ef5b034d2ca (diff) |
As it was made evident by Olaf 'Rhialto' Seibert in the NetBSD PR 34583,
caching the last cluster in the file before extending it considerably
speeds up further lookups. As a consequence this keeps write speed from
gradually decreasing and provides a measurable (up to 2x) performance
increase. Prompted by the diff from Alexander Polakov, ok miod, krw.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/msdosfs/denode.h | 5 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_fat.c | 9 |
2 files changed, 11 insertions, 3 deletions
diff --git a/sys/msdosfs/denode.h b/sys/msdosfs/denode.h index fde57a08ff2..9f17ac79edb 100644 --- a/sys/msdosfs/denode.h +++ b/sys/msdosfs/denode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: denode.h,v 1.23 2010/07/17 19:27:07 guenther Exp $ */ +/* $OpenBSD: denode.h,v 1.24 2012/04/05 09:26:40 mikeb Exp $ */ /* $NetBSD: denode.h,v 1.24 1997/10/17 11:23:39 ws Exp $ */ /*- @@ -116,10 +116,11 @@ struct fatcache { * cache is probably pretty worthless if a file is opened by multiple * processes. */ -#define FC_SIZE 2 /* number of entries in the cache */ +#define FC_SIZE 3 /* number of entries in the cache */ #define FC_LASTMAP 0 /* entry the last call to pcbmap() resolved * to */ #define FC_LASTFC 1 /* entry for the last cluster in the file */ +#define FC_OLASTFC 2 /* entry for the previous last cluster */ #define FCE_EMPTY 0xffffffff /* doesn't represent an actual cluster # */ diff --git a/sys/msdosfs/msdosfs_fat.c b/sys/msdosfs/msdosfs_fat.c index 929ac9a4748..a997a7789c9 100644 --- a/sys/msdosfs/msdosfs_fat.c +++ b/sys/msdosfs/msdosfs_fat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_fat.c,v 1.22 2011/07/04 04:30:41 tedu Exp $ */ +/* $OpenBSD: msdosfs_fat.c,v 1.23 2012/04/05 09:26:40 mikeb Exp $ */ /* $NetBSD: msdosfs_fat.c,v 1.26 1997/10/17 11:24:02 ws Exp $ */ /*- @@ -952,6 +952,13 @@ extendfile(struct denode *dep, uint32_t count, struct buf **bpp, uint32_t *ncp, return (error); } + /* + * Preserve value for the last cluster before extending the file + * to speed up further lookups. + */ + fc_setcache(dep, FC_OLASTFC, dep->de_fc[FC_LASTFC].fc_frcn, + dep->de_fc[FC_LASTFC].fc_fsrcn); + while (count > 0) { /* * Allocate a new cluster chain and cat onto the end of the |