I am experiencing some data loss when writing to a partition with an old version of yaffs and then mounting with a new version.
I have been using the 2.6.32 branch of the android omap kernel (git://android.git.kernel.org/kernel/omap.git), which has a version of yaffs2 patched into it. It looks like it is based off this commit on the yaffs2 repository master branch:
commit 3a263f2d5074abcd6129dff4f1bd1a0ab45a04da
Author: charles <charles>
Date: Wed Sep 9 03:03:01 2009 +0000
Rationalise stats gathering for nand access. Does not instrument mounting.
I am now trying the same 2.6.32 kernel with relatively recent yaffs2 code patched in:
commit 7715144e7d55b2854f907001c432348e4caa5954
Date: Wed Apr 13 10:20:06 2011 +1200
yaffs: Handle attribute size query correctly.
If getxattr() is passed a buffer size of zero then this is a size query.
Return the size of the attribute without copying it out.
When I remount a nand partition that I originally wrote to with the old yaffs2 kernel, using the new yaffs2 kernel, the partition has no data. Additionally, when I boot back into the old kernel again and remount the data is still missing:
<boot old yaffs>
root@homebase:~# mount -t yaffs2 /dev/mtdblock5 /mnt/card/
yaffs: dev is 32505861 name is "mtdblock5"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.5, "mtdblock5"
yaffs_read_super: isCheckpointed 0
root@homebase:~# ls -l /mnt/card/
drw-rw-rw- 1 root root 2048 Jun 22 19:34 lost+found
root@homebase:~# cat /dev/urandom > /mnt/card/testdata
^C
root@homebase:~# cat /proc/yaffs
YAFFS built:May 26 2011 16:35:02
$Id$
$Id$
Device 0 "system_a"
startBlock......... 0
endBlock........... 785
totalBytesPerChunk. 2048
nDataBytesPerChunk. 2048
chunkGroupBits..... 0
chunkGroupSize..... 1
nErasedBlocks...... 767
nReservedBlocks.... 5
blocksInCheckpoint. 0
nTnodesCreated..... 100
nFreeTnodes........ 13
nObjectsCreated.... 200
nFreeObjects....... 95
nFreeChunks........ 49120
nPageWrites........ 1185
nPageReads......... 1186
nBlockErasures..... 1
nGCCopies.......... 0
garbageCollections. 0
passiveGCs......... 0
nRetriedWrites..... 0
nShortOpCaches..... 10
nRetireBlocks...... 0
eccFixed........... 0
eccUnfixed......... 0
tagsEccFixed....... 0
tagsEccUnfixed..... 0
cacheHits.......... 0
nDeletedFiles...... 0
nUnlinkedFiles..... 0
nBackgroudDeletions 0
useNANDECC......... 1
isYaffs2........... 1
inbandTags......... 0
root@homebase:~# ls -l /mnt/card/
drw-rw-rw- 1 root root 2048 Jun 22 19:34 lost+found
-rw-r--r-- 1 root root 2420736 Jun 22 19:34 testdata
root@homebase:~# umount /dev/mtdblock5
save exit: isCheckpointed 1
save exit: isCheckpointed 1
root@homebase:~# sync
<boot new yaffs>
root@homebase:~# mount -t yaffs2 /dev/mtdblock5 /mnt/card/
yaffs: dev is 32505861 name is "mtdblock5" rw
yaffs: passed flags ""
root@homebase:~# cat /proc/yaffs
Multi-version YAFFS built:Jun 22 2011 15:11:04
Device 0 "system_a"
start_block.......... 0
end_block............ 785
total_bytes_per_chunk 2048
use_nand_ecc......... 1
no_tags_ecc.......... 0
is_yaffs2............ 1
inband_tags.......... 0
empty_lost_n_found... 1
disable_lazy_load.... 0
refresh_period....... 500
n_caches............. 10
n_reserved_blocks.... 5
always_check_erased.. 0
data_bytes_per_chunk. 2048
chunk_grp_bits....... 0
chunk_grp_size....... 1
n_erased_blocks...... 785
blocks_in_checkpt.... 0
n_tnodes............. 0
n_obj................ 4
n_free_chunks........ 50304
n_page_writes........ 0
n_page_reads......... 0
n_erasures........... 1
n_gc_copies.......... 0
all_gcs.............. 1
passive_gc_count..... 1
oldest_dirty_gc_count 0
n_gc_blocks.......... 0
bg_gcs............... 0
n_retired_writes..... 0
n_retired_blocks..... 0
n_ecc_fixed.......... 0
n_ecc_unfixed........ 0
n_tags_ecc_fixed..... 0
n_tags_ecc_unfixed... 0
cache_hits........... 0
n_deleted_files...... 0
n_unlinked_files..... 1
refresh_count........ 1
n_bg_deletions....... 0
root@homebase:~# ls /mnt/card/
lost+found
root@homebase:~#
<boot old yaffs again>
root@homebase:~# mount -t yaffs2 /dev/mtdblock5 /mnt/card/
yaffs: dev is 32505861 name is "mtdblock5"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.5, "mtdblock5"
yaffs_read_super: isCheckpointed 0
root@homebase:~# ls -l /mnt/card/
drw-rw-rw- 1 root root 2048 Jun 22 20:02 lost+found
root@homebase:~# cat /proc/yaffs
YAFFS built:May 26 2011 16:35:02
$Id$
$Id$
Device 0 "system_a"
startBlock......... 0
endBlock........... 785
totalBytesPerChunk. 2048
nDataBytesPerChunk. 2048
chunkGroupBits..... 0
chunkGroupSize..... 1
nErasedBlocks...... 785
nReservedBlocks.... 5
blocksInCheckpoint. 0
nTnodesCreated..... 100
nFreeTnodes........ 100
nObjectsCreated.... 200
nFreeObjects....... 96
nFreeChunks........ 50304
nPageWrites........ 0
nPageReads......... 0
nBlockErasures..... 0
nGCCopies.......... 0
garbageCollections. 0
passiveGCs......... 0
nRetriedWrites..... 0
nShortOpCaches..... 10
nRetireBlocks...... 0
eccFixed........... 0
eccUnfixed......... 0
tagsEccFixed....... 0
tagsEccUnfixed..... 0
cacheHits.......... 0
nDeletedFiles...... 0
nUnlinkedFiles..... 1
nBackgroudDeletions 0
useNANDECC......... 1
isYaffs2........... 1
inbandTags......... 0
root@homebase:~#
Are there some versions in which compatibility is not guaranteed? Is there a compatibility mode I should be using or an upgrade utility? I also tried mounting under the new yaffs kernel with "-t yaffs" and got the same result. Any advice or guidelines for mounting the old partitions with the new code would be appreciated, thanks.