vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| pr 34583 in NetBSD. quoting author: "Add a 3rd entry in the cache, which keeps the end position from just before extending a file. This has the desired effect of keeping the write speed constant." please test, comment Index: denode.h ================================================== ================= RCS file: /cvs/src/sys/msdosfs/denode.h,v retrieving revision 1.18 diff -u -p -r1.18 denode.h --- denode.h 1 Mar 2005 14:24:33 -0000 1.18 +++ denode.h 12 Oct 2006 13:41:09 -0000 @@ -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_NEXTTOLASTFC 2 /* entry for a close to the last cluster in the file */ #define FCE_EMPTY 0xffffffff /* doesn't represent an actual cluster # */ @@ -129,6 +130,12 @@ struct fatcache { #define fc_setcache(dep, slot, frcn, fsrcn) \ (dep)->de_fc[slot].fc_frcn = frcn; \ (dep)->de_fc[slot].fc_fsrcn = fsrcn; + +#define fc_last_to_nexttolast(dep) \ + do { \ + (dep)->de_fc[FC_NEXTTOLASTFC].fc_frcn = (dep)->de_fc[FC_LASTFC].fc_frcn; \ + (dep)->de_fc[FC_NEXTTOLASTFC].fc_fsrcn = (dep)->de_fc[FC_LASTFC].fc_fsrcn; \ + } while (0) /* * This is the in memory variant of a dos directory entry. It is usually Index: msdosfs_fat.c ================================================== ================= RCS file: /cvs/src/sys/msdosfs/msdosfs_fat.c,v retrieving revision 1.18 diff -u -p -r1.18 msdosfs_fat.c --- msdosfs_fat.c 3 Oct 2006 19:49:06 -0000 1.18 +++ msdosfs_fat.c 12 Oct 2006 13:41:09 -0000 @@ -82,6 +82,34 @@ int fc_bmapcalls; /* # of times pcbmap int fc_lmdistance[LMMAX]; /* counters for how far off the last * cluster mapped entry was. */ int fc_largedistance; /* off by more than LMMAX */ +int fc_wherefrom, fc_whereto, fc_lastclust; +int pm_fatblocksize; + +#ifdef MSDOSFS_DEBUG +void print_fat_stats(void); + +void +print_fat_stats(void) +{ + int i; + + printf("fc_fileextends=%d fc_lfcempty=%d fc_bmapcalls=%d " + "fc_largedistance=%d [%d->%d=%d] fc_lastclust=%d pm_fatblocksize=%d\n", + fc_fileextends, fc_lfcempty, fc_bmapcalls, fc_largedistance, + fc_wherefrom, fc_whereto, fc_whereto-fc_wherefrom, + fc_lastclust, pm_fatblocksize); + + fc_fileextends = fc_lfcempty = fc_bmapcalls = 0; + fc_wherefrom = fc_whereto = fc_lastclust = 0; + + for (i = 0; i < LMMAX; i++) { + printf("%d:%d ", i, fc_lmdistance[i]); + fc_lmdistance[i] = 0; + } + + printf("\n"); +} +#endif static void fatblock(struct msdosfsmount *, uint32_t, uint32_t *, uint32_t *, uint32_t *); @@ -114,6 +142,8 @@ fatblock(pmp, ofs, bnp, sizep, bop) *sizep = size; if (bop) *bop = ofs % pmp->pm_fatblocksize; + + pm_fatblocksize = pmp->pm_fatblocksize; } /* @@ -205,9 +235,12 @@ pcbmap(dep, findcn, bnp, cnp, sp) */ i = 0; fc_lookup(dep, findcn, &i, &cn); - if ((bn = findcn - i) >= LMMAX) + if ((bn = findcn - i) >= LMMAX) { fc_largedistance++; - else + fc_wherefrom = i; + fc_whereto = findcn; + fc_lastclust = dep->de_fc[FC_LASTFC].fc_frcn; + } else fc_lmdistance[bn]++; /* @@ -1020,6 +1053,8 @@ extendfile(dep, count, bpp, ncp, flags) if (error != E2BIG) return (error); } + + fc_last_to_nexttolast(dep); while (count > 0) { /* |