[Yaffs] scan problem or bug??
Charles Manning
manningc2@actrix.gen.nz
Mon, 31 Jan 2005 11:45:02 +1300
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.
>=20
> 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 thi=
s
> stage!
>=20
> 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.
>=20
> 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 th=
e
> next chunk allocated will be X+1), which is a correct
> behaviour.
>=20
> 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 th=
e=20
wrong value.
You need to ensure that the NAND state querying function is returning the=
=20
correct value. Typically this is done by reading the first chunk in the=20
flash and checcking if it has been used or not.
There are two examples for how to do this in yaffs_ramem2k.c and=20
yaffs_fileem2k.c
>=20
> Moreover this was never a problem with yaffs1, since every time i reboo=
t
> 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=20
yaffs_guts.c This has been chenged in yaffs2 to allow different bacd bloc=
k=20
marking stretegies etc.
>=20
> Does yaffs2 expect only one intialisation? If so what about reboots??
Like YAFFS1, YAFFS2 expects multiple initialisations and even powerloss a=
t=20
random times.
>=20
> Is this a bug??? Or am I missing something while reinitalizing?
Debug through the block state querying function to see wht it returns emp=
y=20
instead of NEEDS_SCANNING.
-- CHarles