[U-Boot] [PATCH 1/7] JFFS2: Bug fix for summary support

Baidu Liu liucai.lfn at gmail.com
Fri Apr 29 15:49:44 CEST 2011


Hi,  Detlev :

2011/4/29 Detlev Zundel <dzu at denx.de>:
> Hi,
>
>>  1/ Get the latest DIRENT
>>  For example, if you create a file in linux jffs2 which config summary
>>  support, then you delete the file , you will not see the file  in
>>  linux jffs2. But you can also see this file in uboot after you reset
>>  the system. That is because all the nodes in jffs2 which config summary
>>  will not be marked as obsolete. The deleted file's DIRENT node will be
>>  seen in uboot. So what we need to do is to get the latest DIRENT whose
>>  ino in DIRENT is 0.
>
> Sorry, but I do not understand that last sentence.  Can you clarify this
> please?

This is just give an example. If you create a file, then you DELETE it
in jffs2 .
In previous code where you do NOT config SUMMARY. There will be two
DIRENT nodes in flash. One is obsoleted where the ino=1, another one
is valid where the ino=0. When we type "ls " command, the file will
NOT shown because uboot will not show the DIRENT where the ino =0
which means the file is deleted.
But when we config SUMMARY in  kernel jffs2. The two DIRENTs are BOTH
valid. When we type "ls " command, the file will be  SHOWN  because we
find the first DIRENT where the ino is not 0. The result is  obviously
wrong.
So what we need to do is to find the DIRENT with the latest version.
In this example ,the second DIRENT has highest version which means
latest. And the ino is 0. Then we will not show it.

>>  Than we will not see this file in uboot which is
>>  what we want.
>>
>>  2/ Add CONFIG_SYS_JFFS2_SORT_FRAGMENTS definition,if we config jffs2
>>  summary in uboot.
>>  All the inodes of a file will not marked as obsolete, if they do not
>>  sort in the list struct b_node *, the latest data in inode may be
>>  overwritten by the older one.
>
> Also I have trouble making sense of this text.
>
There may have many data inode in jfffs2 which represent the same
range in the same file, when we use SUMMARY. They are overlapped. But
only the data inode which has the latest version represent the actual
data. So we need to sort the data inode, where we make the latest data
inode after the obsoleted data inode. Then the latest data inode will
not be overwritten when use use "fsload" command in uboot.

>>
>> Signed-off-by: Baidu Liu <liucai.lfn at gmail.com>
>> ---
>>  fs/jffs2/jffs2_1pass.c      |   17 ++++++++++++-----
>>  fs/jffs2/jffs2_nand_1pass.c |   17 +++++++++++++----
>>  include/jffs2/jffs2.h       |   10 ++++++++++
>>  3 files changed, 35 insertions(+), 9 deletions(-)
>
> [...]
>
>> diff --git a/include/jffs2/jffs2.h b/include/jffs2/jffs2.h
>> index 651f94c..5b006c0 100644
>> --- a/include/jffs2/jffs2.h
>> +++ b/include/jffs2/jffs2.h
>> @@ -41,6 +41,16 @@
>>  #include <asm/types.h>
>>  #include <jffs2/load_kernel.h>
>>
>> +#ifdef CONFIG_JFFS2_SUMMARY
>> +#ifndef CONFIG_SYS_JFFS2_SORT_FRAGMENTS
>> +/*
>> +we should define CONFIG_SYS_JFFS2_SORT_FRAGMENTS,if
>> +CONFIG_JFFS2_SUMMARY is enabled.
>> +*/
>> +#define CONFIG_SYS_JFFS2_SORT_FRAGMENTS
>> +#endif
>> +#endif
>> +
>>  #define JFFS2_SUPER_MAGIC 0x72b6
>>
>>  /* Values we may expect to find in the 'magic' field */
>
> If JFFS2_SUMMARY _needs_ SORT_FRAGMENTS, then we should say so, i.e.
>
> /*
> CONFIG_JFFS2_SUMMARY will not work correctly without
> CONFIG_SYS_JFFS2_SORT_FRAGMENTS
> */
>
> Alas, technically I do not understand why that is the case.  So I invite
> people more knowledgeable with JFFS2 to comment on this bit.
>
> [time passes]
>
> Wait a minute - I tried to understand the code here - is it possible
> that SORT_FRAGMENTS really is needed _whenever_ we have a read-write
> JFFS2 filesystem?  I.e. even without summary support we will have
> problems without SORT_FRAGMENTS?
>
No, SORT_FRAGMENTS only need when SUMMARY is configed.
Because all the nodes including the DIRENT inode and DATA inode are
all valid. So we need to sort them.

> Wow, if this is true, then the option is certainly named completely
> misleading and most boards using JFFS2 actually use incorrect code....
>
The previous code works well when SUMAMRY is not configed. We have
plenty of  board use
JFFS2 in uboot where the SUMMARY is not configed. But the uboot does
not work when sumamry configed, so I submit these patches to fix this
issue.

> We should define this option by default and only let people undefine it
> if they know exactly what they do.
>
We do not need to define SORT when we do not use SUMMARY. But we mush
use SORT when we use SUMMARY.

This patch is most importent in the 7 patches.

The jffs2 inode is not easy to understand. And I think the comments in
the patch is enough if the reader know about jffs2. Too many commants
is not need just as previous code did not give us too many comments.
In kernel there are even little comment to explain how the jffs2
works.

Thanks


More information about the U-Boot mailing list