summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/msdosfs/denode.h5
-rw-r--r--sys/msdosfs/msdosfs_fat.c9
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