[U-Boot] [PATCH 3/7] JFFS2: Calculate buf_len before we read data from flash
Baidu Liu
liucai.lfn at gmail.com
Fri Apr 29 16:17:11 CEST 2011
Hi,Detlev
2011/4/29 Detlev Zundel <dzu at denx.de>:
> Hi Baidu,
>
>> 1/ We should calculate the buf_len before we call
>> get_fl_mem().
>
> If I read your change correctly, then do you mean the following?
>
> When we know what we want to read, we can calculate buf_len to be the
> maximum size of the data to be read. Without this, we usually read
> EMPTY_SCAN_SIZE which is too much.
Yes,you are right.
> This is only an optimization change.
>
> Maybe this text will help people understand better what the change tries
> to do.
The patch comments may be enough to explain what my changes is. We can see the
code:
buf_len = min_t() everywhere the get_fl_mem() called.
>> diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
>> index 8eb77b1..be6ac78 100644
>> --- a/fs/jffs2/jffs2_1pass.c
>> +++ b/fs/jffs2/jffs2_1pass.c
>> @@ -1643,6 +1643,8 @@ jffs2_1pass_build_lists(struct part_info * part)
>> case JFFS2_NODETYPE_INODE:
>> if (buf_ofs + buf_len < ofs + sizeof(struct
>> jffs2_raw_inode)) {
>> + buf_len = min_t(uint32_t, buf_size, sector_ofs
>> + + part->sector_size - ofs);
>
> I am somewhat uncomfortable that "buf_len" is used in the if condition
> before it is recalculated inside. Are you sure that this cannot lead to
> problems, i.e. can buf_len become larger than it was when entering the
> condition?
It works well in my boards.
More information about the U-Boot
mailing list