[Yaffs] power fail testing
Sergei Sharonov
Sergei.Sharonov@Halliburton.com
Thu, 28 Apr 2005 11:24:31 -0500
Charles,
> You should find the power fail stuff very robust (ie. zero=20
> problems). If you=20
> don't then please shout ***loud***.
the first problem found after a dozen power cycles ;-(
I have a counter file that contains a number=20
that needs to be incremented. Increment is done as:
1. Read the number from the counter file (open as O_RDONLY, read, close)
2. Increment the number
3. Write the number to a temporary file
4. Rename temporary file to counter file
Rename() suppose to be atomic per=20
http://www.opengroup.org/onlinepubs/007908799/xsh/rename.html:
"If the link named by the new argument exists, it is removed and=20
old renamed to new. In this case, a link named new will remain=20
visible to other processes throughout the renaming operation and=20
will refer either to the file referred to by new or old before=20
the operation began."
After a few power cycle tests the counter file disappeared, but=20
the temp file is still there. rename() never reported failure.
=20
-------------------Code---------------------
ret =3D rename(FnameBlockTmp,FnameBlock);
if(ret < 0) terminate(instance,ERR,
"writer: failed to rename tmp block file %s",
FnameBlockTmp);
------------------Output-------------------
running external script /mnt/flash/run.sh
writer 0 started
instance 0 terminated with status -1
writer: failed to open block file /mnt/flash/blockno0
writing status to </mnt/flash/status0>
# cd /mnt/flash/
# ls
blockno.tmp0 jffs2tester run.sh test0 write.sh
init.sh lost+found status0 verify.sh
# cat /proc/yaffs
YAFFS built:Apr 20 2005 14:39:45
$Id: yaffs_fs.c,v 1.35 2004/10/20 20:12:43 charles Exp $
$Id: yaffs_guts.c,v 1.37 2004/10/20 20:12:43 charles Exp $
Device yaffs
startBlock......... 1
endBlock........... 8191
chunkGroupBits..... 2
chunkGroupSize..... 4
nErasedBlocks...... 7
nTnodesCreated..... 33400
nFreeTnodes........ 2
nObjectsCreated.... 32800
nFreeObjects....... 83
nFreeChunks........ 187105
nPageWrites........ 6
nPageReads......... 14
nBlockErasures..... 0
nGCCopies.......... 0
garbageCollections. 0
passiveGCs......... 0
nRetriedWrites..... 0
nRetireBlocks...... 0
eccFixed........... 0
eccUnfixed......... 0
tagsEccFixed....... 0
tagsEccUnfixed..... 8
cacheHits.......... 0
nDeletedFiles...... 32706
nUnlinkedFiles..... 32706
nBackgroudDeletions 0
useNANDECC......... 1
#
-------------------------------------------
Sergei