[Yaffs] Why tags->sequenceNumber is not 0xffffffff when the …

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Zhen Feng
Date:  
To: yaffs
Subject: [Yaffs] Why tags->sequenceNumber is not 0xffffffff when the chunk is deleted ???

I operated my nand flash(128Mb,2k bytes * 64 pages = 128Kb/block) as follows:

[root@PMPBoard /]# flash_eraseall /dev/mtd/4
Erasing 128 Kibyte @ xxxxx -- xx % complete
.....

[root@PMPBoard /]# mount -t yaffs2 /dev/mtdblock/4 /mnt
yaffs: dev is 7940 name is "1f:04"
yaffs: Attempting MTD mount on 31.4, "1f:04"
yaffs: yaffs_GutsInitialise()
yaffs: yaffs_GutsInitialise() done.

[root@PMPBoard /mnt]# df
Filesystem           1k-blocks      Used Available Use% Mounted on
...
/dev/mtdblock/4          80384       768     79616   1% /mnt


[root@PMPBoard /mnt]# cp /zImage ./

....
//Object Header Block 1 chunk 0

Allocated block 1, seq 4097, 627 left
nandmtd2_ReadChunkWithTagsToNAND chunk 0 data c039b800 tags c3f5dc40 //check bad
packed tags obj -1 chunk -1 byte -1 seq -1
ext.tags eccres 0 blkbad 0 chused 0 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
Writing chunk 0 tags 261 0
nandmtd2_WriteChunkWithTagsToNAND chunk 0 data c000e000 tags c3f5dddc
packed tags obj 268435717 chunk -2147483647 byte 0 seq 4097
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk0 byte 0 del 0 ser 1 seq 4097

//data chunk 1
nandmtd2_ReadChunkWithTagsToNAND chunk 1 data c000e000 tags c3f5dd18
packed tags obj -1 chunk -1 byte -1 seq -1
ext.tags eccres 0 blkbad 0 chused 0 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
Writing chunk 1 tags 261 1
nandmtd2_WriteChunkWithTagsToNAND chunk 1 data c3df3000 tags c3f5ddb0
packed tags obj 261 chunk 1 byte 2048 seq 4097
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk1 byte 2048 del 0 ser 1 seq 4097
nandmtd2_ReadChunkWithTagsToNAND chunk 2 data c000e000 tags c3f5dd18
packed tags obj -1 chunk -1 byte -1 seq -1
ext.tags eccres 0 blkbad 0 chused 0 obj 0 chunk0 byte 0 del 0 ser 0 seq

....
//Block 2,
Allocated block 2, seq 4098, 626 left
nandmtd2_ReadChunkWithTagsToNAND chunk 64 data c000e000 tags c3f5dd18
packed tags obj -1 chunk -1 byte -1 seq -1
ext.tags eccres 0 blkbad 0 chused 0 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
Writing chunk 64 tags 261 64
nandmtd2_WriteChunkWithTagsToNAND chunk 64 data c3d84800 tags c3f5ddb0
packed tags obj 261 chunk 64 byte 2048 seq 4098
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk64 byte 2048 del 0 ser 1 seq 4098

....//Block 3,4,5,6

//Block 7, The last one
Allocated block 7, seq 4103, 621 left
nandmtd2_ReadChunkWithTagsToNAND chunk 384 data c000e000 tags c3f5dd18
packed tags obj -1 chunk -1 byte -1 seq -1
ext.tags eccres 0 blkbad 0 chused 0 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
Writing chunk 384 tags 261 384
nandmtd2_WriteChunkWithTagsToNAND chunk 384 data c3c67800 tags c3f5ddb0
packed tags obj 261 chunk 384 byte 2048 seq 4103
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk384 byte 2048 del 0 ser 1 seq 410

....
Writing chunk 414 tags 261 0
nandmtd2_WriteChunkWithTagsToNAND chunk 414 data c000e000 tags c3f5decc
packed tags obj 268435717 chunk -2147483647 byte 844056 seq 4103
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk0 byte 0 del 0 ser 2 seq 4103
line 2863 delete of chunk 64.
//finished

[root@PMPBoard /mnt]# df
...
/dev/mtdblock/4          80384      1596     78788   2% /mnt


[root@PMPBoard /mnt]# cat /proc/yaffs

$Id: yaffs_fs.c,v 1.29 2005/08/11 01:07:43 marty Exp $
$Id: yaffs_guts.c,v 1.18 2005/08/16 02:28:04 charles Exp $

Device 0 "U-Disk"
startBlock......... 0
endBlock........... 627
chunkGroupBits..... 0
chunkGroupSize..... 1
nErasedBlocks...... 621
nTnodesCreated..... 100
nFreeTnodes........ 69
nObjectsCreated.... 100
nFreeObjects....... 95
nFreeChunks........ 39778
nPageWrites........ 0
nPageReads......... 0
nBlockErasures..... 0
nGCCopies.......... 0
garbageCollections. 0
passiveGCs......... 0
nRetriedWrites..... 0
nRetireBlocks...... 0
eccFixed........... 0
eccUnfixed......... 0
tagsEccFixed....... 0
tagsEccUnfixed..... 0
cacheHits.......... 0
nDeletedFiles...... 0
nUnlinkedFiles..... 0
nBackgroudDeletions 0
useNANDECC......... 1
isYaffs2........... 1

[root@PMPBoard /mnt]# rm -rf zImage

nandmtd2_ReadChunkWithTagsToNAND chunk 414 data c000e000 tags 00000000
nandmtd2_ReadChunkWithTagsToNAND chunk 415 data c039b800 tags c3f5dba0
packed tags obj -1 chunk -1 byte -1 seq -1
ext.tags eccres 0 blkbad 0 chused 0 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
Writing chunk 415 tags 261 0

//Update object header
nandmtd2_WriteChunkWithTagsToNAND chunk 415 data c000e000 tags c3f5dd3c
packed tags obj 268435717 chunk -2147483645 byte 0 seq 4103
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk0 byte 0 del 0 ser 3 seq 4103
line 2863 delete of chunk 478
yaffs_put_inode: ino 261, count 1
yaffs_delete_inode: ino 261, count 0 object exists
soft delete chunk 477
soft delete chunk 476
....
soft delete chunk 66
soft delete chunk 65
yaffs_clear_inode: ino 261, count 0 object exists


[root@PMPBoard /]# umount /mnt/
[root@PMPBoard /]# mount -t yaffs2 /dev/mtdblock/4 /mnt
....
yaffs: yaffs_GutsInitialise()
//Scan the last page of all the block
nandmtd2_QueryNANDBlock 0
nandmtd2_ReadChunkWithTagsToNAND chunk 0 data 00000000 tags c3f5dd24
packed tags obj 268435717 chunk -2147483647 byte 0 seq 4097
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk0 byte 0 del 0 ser 0 seq 4097
block is bad seq 4097 state 2
nandmtd2_QueryNANDBlock 1
nandmtd2_ReadChunkWithTagsToNAND chunk 64 data 00000000 tags c3f5dd24
packed tags obj 261 chunk 64 byte 2048 seq 4098
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk64 byte 2048 del 0 ser 0 seq 4098
block is bad seq 4098 state 2
nandmtd2_QueryNANDBlock 2
nandmtd2_ReadChunkWithTagsToNAND chunk 128 data 00000000 tags c3f5dd24
packed tags obj 261 chunk 128 byte 2048 seq 4099
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk128 byte 2048 del 0 ser 0 seq 4099
block is bad seq 4099 state 2
nandmtd2_QueryNANDBlock 3
nandmtd2_ReadChunkWithTagsToNAND chunk 192 data 00000000 tags c3f5dd24
packed tags obj 261 chunk 192 byte 2048 seq 4100
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk192 byte 2048 del 0 ser 0 seq 4100
block is bad seq 4100 state 2
nandmtd2_QueryNANDBlock 4
nandmtd2_ReadChunkWithTagsToNAND chunk 256 data 00000000 tags c3f5dd24
packed tags obj 261 chunk 256 byte 2048 seq 4101
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk256 byte 2048 del 0 ser 0 seq 4101
block is bad seq 4101 state 2
nandmtd2_QueryNANDBlock 5
nandmtd2_ReadChunkWithTagsToNAND chunk 320 data 00000000 tags c3f5dd24
packed tags obj 261 chunk 320 byte 2048 seq 4102
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk320 byte 2048 del 0 ser 0 seq 4102
block is bad seq 4102 state 2
nandmtd2_QueryNANDBlock 6
nandmtd2_ReadChunkWithTagsToNAND chunk 384 data 00000000 tags c3f5dd24
packed tags obj 261 chunk 384 byte 2048 seq 4103
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk384 byte 2048 del 0 ser 0 seq 4103
block is bad seq 4103 state 2
nandmtd2_QueryNANDBlock 7
nandmtd2_ReadChunkWithTagsToNAND chunk 448 data 00000000 tags c3f5dd24
packed tags obj -1 chunk -1 byte -1 seq -1
ext.tags eccres 0 blkbad 0 chused 0 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
block is bad seq 0 state 3
....

//scan all YAFFS_BLOCK_STATE_NEEDS_SCANNING marked blocks (that is, block 7- block 0)
nandmtd2_ReadChunkWithTagsToNAND chunk 447 data 00000000 tags c3f5ddb0
packed tags obj -1 chunk -1 byte -1 seq -1
ext.tags eccres 0 blkbad 0 chused 0 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
nandmtd2_ReadChunkWithTagsToNAND chunk 446 data 00000000 tags c3f5ddb0
packed tags obj -1 chunk -1 byte -1 seq -1
ext.tags eccres 0 blkbad 0 chused 0 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
....

//Object Header
nandmtd2_ReadChunkWithTagsToNAND chunk 415 data 00000000 tags c3f5ddb0
packed tags obj 268435717 chunk -2147483645 byte 0 seq 4103
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk0 byte 0 del 0 ser 0 seq 4103
yaffs: Tnodes added
nandmtd2_ReadChunkWithTagsToNAND chunk 415 data c000e000 tags 00000000
nandmtd2_ReadChunkWithTagsToNAND chunk 414 data 00000000 tags c3f5ddb0
packed tags obj 268435717 chunk -2147483647 byte 844056 seq 4103
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk0 byte 0 del 0 ser 0 seq 4103
line 4661 delete of chunk 478

//data chunks
nandmtd2_ReadChunkWithTagsToNAND chunk 413 data 00000000 tags c3f5ddb0
packed tags obj 261 chunk 413 byte 280 seq 4103
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk413 byte 280 del 0 ser 0 seq 4103
nandmtd2_ReadChunkWithTagsToNAND chunk 412 data 00000000 tags c3f5ddb0
packed tags obj 261 chunk 412 byte 2048 seq 4103
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk412 byte 2048 del 0 ser 0 seq 4103
nandmtd2_ReadChunkWithTagsToNAND chunk 411 data 00000000 tags c3f5ddb0
packed tags obj 261 chunk 411 byte 2048 seq 4103
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk411 byte 2048 del 0 ser 0 seq 4103
....
nandmtd2_ReadChunkWithTagsToNAND chunk 2 data 00000000 tags c3f5ddb0
packed tags obj 261 chunk 2 byte 2048 seq 4097
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk2 byte 2048 del 0 ser 0 seq 4097
nandmtd2_ReadChunkWithTagsToNAND chunk 1 data 00000000 tags c3f5ddb0
packed tags obj 261 chunk 1 byte 2048 seq 4097
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk1 byte 2048 del 0 ser 0 seq 4097
nandmtd2_ReadChunkWithTagsToNAND chunk 0 data 00000000 tags c3f5ddb0
packed tags obj 268435717 chunk -2147483647 byte 0 seq 4097
ext.tags eccres 0 blkbad 0 chused 1 obj 261 chunk0 byte 0 del 0 ser 0 seq 4097
line 4661 delete of chunk 64
yaffs: yaffs_GutsInitialise() done.


[root@PMPBoard /]# df
....
/dev/mtdblock/4          80384      1596     78788   2% /mnt


Comparing to the avaialbe space after copying a file to the flash, the number of used
space is the same, but now there are no files in the flash!
If I repeated cp, rm, umount, mount again and again, my available space becomes lower.

why no block could became dirty and be erased???
When does these deleted block become avaialable again??