Re: [Yaffs] scan problem or bug??

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Charles Manning
Date:  
To: Abhishek Bhattacharya, yaffs
Subject: Re: [Yaffs] scan problem or bug??
On Friday 28 January 2005 19:38, Abhishek Bhattacharya wrote:
> Hi
> Working with yaffs2 I have faced a strange problem. Intially to
> initialise the file system, i make a call to
> yaffs_StartUp() and then yaffs_mount("/flash"). I am only using flash
> device.
>
> Following this I create files, which are successfully created. To see
> the created files I use dumpDir("/flash"),
> which clearly shows the created file and the size. All is fine upto this
> stage!
>
> But problem starts, once I restart the system and try to reinitialize.
> Well once I do this , the return messages
> show that all blocks starting from START BLOCK to END BLOCK are empty. (
> Even though previously we have created
> a file of 1 MB). Next after this if I call dumpDir("/flash") I get only
> lost+found dir, and the previously created file is simply gone.
>
> But the funny thing is that , when I try to create another file after
> reinitalization, it actually allocates a chunk which is the next
> chunk from the last chunk used ( Suppose last chunk used was X, then the
> next chunk allocated will be X+1), which is a correct
> behaviour.
>
> Now I have seen , that in yaffs_Scan() we
> yaffs_QueryInitialBlockState(), inside which the state is always
> returned as EMPTY.
> Therefore every time you scan all blocks definetely turn up as EMPTY,
> and though there exists data in the flash, it shows 0 files
> and complete flash as empty!


All this is consistent with the initial block state querying returning the
wrong value.

You need to ensure that the NAND state querying function is returning the
correct value. Typically this is done by reading the first chunk in the
flash and checcking if it has been used or not.

There are two examples for how to do this in yaffs_ramem2k.c and
yaffs_fileem2k.c

>
> Moreover this was never a problem with yaffs1, since every time i reboot
> I used to reinitialize using the same sequence, and I used
> to get all files and directories intact!


This is most likely because the equivalent code in YAFFS1 was done in
yaffs_guts.c This has been chenged in yaffs2 to allow different bacd block
marking stretegies etc.

>
> Does yaffs2 expect only one intialisation? If so what about reboots??


Like YAFFS1, YAFFS2 expects multiple initialisations and even powerloss at
random times.

>
> Is this a bug??? Or am I missing something while reinitalizing?


Debug through the block state querying function to see wht it returns empy
instead of NEEDS_SCANNING.

-- CHarles