projects
/
yaffs2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
yaffs Some cleanups.
[yaffs2.git]
/
yaffs_guts.c
diff --git
a/yaffs_guts.c
b/yaffs_guts.c
index 65e33a644b958c09b946f8a14c80d3bcbf933a05..d77ee4745d79e29d1e18ceeafc57a2b591c38a66 100644
(file)
--- a/
yaffs_guts.c
+++ b/
yaffs_guts.c
@@
-1,7
+1,7
@@
/*
* YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
*
/*
* YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
*
- * Copyright (C) 2002-20
07
Aleph One Ltd.
+ * Copyright (C) 2002-20
10
Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering
*
* Created by Charles Manning <charles@aleph1.co.uk>
* for Toby Churchill Ltd and Brightstar Engineering
*
* Created by Charles Manning <charles@aleph1.co.uk>
@@
-10,10
+10,6
@@
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
-
-const char *yaffs_guts_c_version =
- "$Id: yaffs_guts.c,v 1.120 2010-03-15 23:10:34 charles Exp $";
-
#include "yportenv.h"
#include "yaffs_trace.h"
#include "yportenv.h"
#include "yaffs_trace.h"
@@
-3428,8
+3424,10
@@
static unsigned yaffs_FindBlockForGarbageCollection(yaffs_Device *dev,
int maxThreshold = dev->param.nChunksPerBlock/2;
threshold = background ?
(dev->gcNotDone + 2) * 2 : 0;
int maxThreshold = dev->param.nChunksPerBlock/2;
threshold = background ?
(dev->gcNotDone + 2) * 2 : 0;
- threshold = max(threshold, YAFFS_GC_PASSIVE_THRESHOLD);
- threshold = min(threshold, maxThreshold);
+ if(threshold <YAFFS_GC_PASSIVE_THRESHOLD)
+ threshold = YAFFS_GC_PASSIVE_THRESHOLD;
+ if(threshold > maxThreshold)
+ threshold = maxThreshold;
iterations = nBlocks / 16 + 1;
if (iterations > 100)
iterations = nBlocks / 16 + 1;
if (iterations > 100)
@@
-3463,11
+3461,18
@@
static unsigned yaffs_FindBlockForGarbageCollection(yaffs_Device *dev,
selected = dev->gcDirtiest;
}
selected = dev->gcDirtiest;
}
- if(!selected && dev->param.isYaffs2 && dev->gcNotDone >= ( background ? 10 : 20)){
+ /*
+ * If nothing has been selected for a while, try selecting the oldest dirty
+ * because that's gumming up the works.
+ */
+
+ if(!selected && dev->param.isYaffs2 &&
+ dev->gcNotDone >= ( background ? 10 : 20)){
yaffs_FindOldestDirtySequence(dev);
if(dev->oldestDirtyBlock > 0) {
selected = dev->oldestDirtyBlock;
dev->gcDirtiest = selected;
yaffs_FindOldestDirtySequence(dev);
if(dev->oldestDirtyBlock > 0) {
selected = dev->oldestDirtyBlock;
dev->gcDirtiest = selected;
+ dev->oldestDirtyGCs++;
bi = yaffs_GetBlockInfo(dev, selected);
dev->gcPagesInUse = bi->pagesInUse - bi->softDeletions;
} else
bi = yaffs_GetBlockInfo(dev, selected);
dev->gcPagesInUse = bi->pagesInUse - bi->softDeletions;
} else
@@
-3481,6
+3486,8
@@
static unsigned yaffs_FindBlockForGarbageCollection(yaffs_Device *dev,
dev->param.nChunksPerBlock - dev->gcPagesInUse,
prioritised));
dev->param.nChunksPerBlock - dev->gcPagesInUse,
prioritised));
+ if(background)
+ dev->backgroundGCs++;
dev->gcDirtiest = 0;
dev->gcPagesInUse = 0;
dev->gcNotDone = 0;
dev->gcDirtiest = 0;
dev->gcPagesInUse = 0;
dev->gcNotDone = 0;
@@
-3573,9
+3580,9
@@
static int yaffs_CheckGarbageCollection(yaffs_Device *dev, int background)
}
if (dev->gcBlock > 0) {
}
if (dev->gcBlock > 0) {
- dev->
garbageCollection
s++;
+ dev->
allGC
s++;
if (!aggressive)
if (!aggressive)
- dev->passiveG
arbageCollection
s++;
+ dev->passiveG
C
s++;
T(YAFFS_TRACE_GC,
(TSTR
T(YAFFS_TRACE_GC,
(TSTR
@@
-3603,11
+3610,11
@@
static int yaffs_CheckGarbageCollection(yaffs_Device *dev, int background)
* Garbage collects. Intended to be called from a background thread.
* Returns non-zero if at least half the free chunks are erased.
*/
* Garbage collects. Intended to be called from a background thread.
* Returns non-zero if at least half the free chunks are erased.
*/
-int yaffs_BackgroundGarbageCollect(yaffs_Device *dev)
+int yaffs_BackgroundGarbageCollect(yaffs_Device *dev
, unsigned urgency
)
{
int erasedChunks = dev->nErasedBlocks * dev->param.nChunksPerBlock;
{
int erasedChunks = dev->nErasedBlocks * dev->param.nChunksPerBlock;
- T(YAFFS_TRACE_BACKGROUND, (TSTR("Background gc
" TENDSTR)
));
+ T(YAFFS_TRACE_BACKGROUND, (TSTR("Background gc
%u" TENDSTR),urgency
));
yaffs_CheckGarbageCollection(dev, 1);
return erasedChunks > dev->nFreeChunks/2;
yaffs_CheckGarbageCollection(dev, 1);
return erasedChunks > dev->nFreeChunks/2;
@@
-6760,7
+6767,7
@@
static int yaffs_ScanBackwards(yaffs_Device *dev)
* the current allocation block.
*/
* the current allocation block.
*/
- T(YAFFS_TRACE_
ALWAYS
,
+ T(YAFFS_TRACE_
SCAN
,
(TSTR("Partially written block %d detected" TENDSTR),
blk));
}
(TSTR("Partially written block %d detected" TENDSTR),
blk));
}
@@
-7905,8
+7912,10
@@
int yaffs_GutsInitialise(yaffs_Device *dev)
/* OK, we've finished verifying the device, lets continue with initialisation */
/* More device initialisation */
/* OK, we've finished verifying the device, lets continue with initialisation */
/* More device initialisation */
- dev->garbageCollections = 0;
- dev->passiveGarbageCollections = 0;
+ dev->allGCs = 0;
+ dev->passiveGCs = 0;
+ dev->oldestDirtyGCs = 0;
+ dev->backgroundGCs = 0;
dev->gcBlockFinder = 0;
dev->bufferedBlock = -1;
dev->doingBufferedBlockRewrite = 0;
dev->gcBlockFinder = 0;
dev->bufferedBlock = -1;
dev->doingBufferedBlockRewrite = 0;