annotate yaffs_packedtags1.c @ 403:205fa93db422

yaffs New background garbage collector and related tweaks This commit - introduces the yaffs background garbage collection feature - tweaks the foregound garbage collection to do less work - changes the way auto-checkpointing works - tweaks the block refreshing logic. The aim of the background garbage collector is to do at least some of the garbage collection in the background so that writing operations will not have to do as much garbage collection which should make writes faster. The amount of background garbage collection is controlled by the ratio between the amount of erased space vs the amount of free space: * If less than quarter of free space is erased, then background gc is frequent. * Else if less than a half of the free space is erased, then background gc is still done reasonably frequently. * else (at least half of the free space is erased) the background gc is done infrequently. Background gc is not attempted if the partition is checkpointed since that would invalidate the checkpoint. The auto-checkpointing feature has changed slightly. If the yaffs_auto_checkpoint value is set to 1 or 2 then the auto checkpointing will be blocked if the erased space is less than half the free space (ie. the auto-checkpointing is blocked to allow background gc to progress). Oring in 4 into the yaffs_auto_checkpoint will do a one-shot override, forcing a checkpoint and suspending background gc until the partition is dirtied by a write, erase etc. The block refreshing control has been changed. The dev->param.refreshPeriod now controls how many blocks are garbage collected before another refresh is performed. Values around 1000 probably make the best sense. Signed-off-by: Charles Manning <cdhmanning@gmail.com>
author Charles Manning <cdhmanning@gmail.com>
date Fri, 16 Apr 2010 15:39:16 +1200
parents 4c1611b9a4d7
children b5309c9b6d7f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
168
b8f20fdc3a58 normalise licence headers and attributions
wookey <wookey>
parents: 77
diff changeset
1 /*
b8f20fdc3a58 normalise licence headers and attributions
wookey <wookey>
parents: 77
diff changeset
2 * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
b8f20fdc3a58 normalise licence headers and attributions
wookey <wookey>
parents: 77
diff changeset
3 *
b8f20fdc3a58 normalise licence headers and attributions
wookey <wookey>
parents: 77
diff changeset
4 * Copyright (C) 2002-2007 Aleph One Ltd.
b8f20fdc3a58 normalise licence headers and attributions
wookey <wookey>
parents: 77
diff changeset
5 * for Toby Churchill Ltd and Brightstar Engineering
b8f20fdc3a58 normalise licence headers and attributions
wookey <wookey>
parents: 77
diff changeset
6 *
b8f20fdc3a58 normalise licence headers and attributions
wookey <wookey>
parents: 77
diff changeset
7 * Created by Charles Manning <charles@aleph1.co.uk>
b8f20fdc3a58 normalise licence headers and attributions
wookey <wookey>
parents: 77
diff changeset
8 *
b8f20fdc3a58 normalise licence headers and attributions
wookey <wookey>
parents: 77
diff changeset
9 * This program is free software; you can redistribute it and/or modify
b8f20fdc3a58 normalise licence headers and attributions
wookey <wookey>
parents: 77
diff changeset
10 * it under the terms of the GNU General Public License version 2 as
b8f20fdc3a58 normalise licence headers and attributions
wookey <wookey>
parents: 77
diff changeset
11 * published by the Free Software Foundation.
b8f20fdc3a58 normalise licence headers and attributions
wookey <wookey>
parents: 77
diff changeset
12 */
b8f20fdc3a58 normalise licence headers and attributions
wookey <wookey>
parents: 77
diff changeset
13
6
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
14 #include "yaffs_packedtags1.h"
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
15 #include "yportenv.h"
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
16
271
c0dfae9e8073 Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents: 171
diff changeset
17 void yaffs_PackTags1(yaffs_PackedTags1 *pt, const yaffs_ExtendedTags *t)
6
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
18 {
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
19 pt->chunkId = t->chunkId;
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
20 pt->serialNumber = t->serialNumber;
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
21 pt->byteCount = t->byteCount;
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
22 pt->objectId = t->objectId;
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
23 pt->ecc = 0;
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
24 pt->deleted = (t->chunkDeleted) ? 0 : 1;
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
25 pt->unusedStuff = 0;
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
26 pt->shouldBeFF = 0xFFFFFFFF;
77
794fd064bd36 lindent
marty <marty>
parents: 7
diff changeset
27
6
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
28 }
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
29
271
c0dfae9e8073 Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents: 171
diff changeset
30 void yaffs_UnpackTags1(yaffs_ExtendedTags *t, const yaffs_PackedTags1 *pt)
6
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
31 {
77
794fd064bd36 lindent
marty <marty>
parents: 7
diff changeset
32 static const __u8 allFF[] =
794fd064bd36 lindent
marty <marty>
parents: 7
diff changeset
33 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
794fd064bd36 lindent
marty <marty>
parents: 7
diff changeset
34 0xff };
794fd064bd36 lindent
marty <marty>
parents: 7
diff changeset
35
794fd064bd36 lindent
marty <marty>
parents: 7
diff changeset
36 if (memcmp(allFF, pt, sizeof(yaffs_PackedTags1))) {
6
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
37 t->blockBad = 0;
274
4c1611b9a4d7 More formatting
charles <charles>
parents: 271
diff changeset
38 if (pt->shouldBeFF != 0xFFFFFFFF)
6
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
39 t->blockBad = 1;
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
40 t->chunkUsed = 1;
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
41 t->objectId = pt->objectId;
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
42 t->chunkId = pt->chunkId;
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
43 t->byteCount = pt->byteCount;
77
794fd064bd36 lindent
marty <marty>
parents: 7
diff changeset
44 t->eccResult = YAFFS_ECC_RESULT_NO_ERROR;
6
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
45 t->chunkDeleted = (pt->deleted) ? 0 : 1;
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
46 t->serialNumber = pt->serialNumber;
77
794fd064bd36 lindent
marty <marty>
parents: 7
diff changeset
47 } else {
794fd064bd36 lindent
marty <marty>
parents: 7
diff changeset
48 memset(t, 0, sizeof(yaffs_ExtendedTags));
6
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
49 }
c31b20a2342e *** empty log message ***
charles <charles>
parents:
diff changeset
50 }