diff mbox

[U-Boot] fix yaffs2 with inband-tags option, mtd_block_markbad & mtd_block_isbad parameter error.

Message ID OF377CF5DC.91728031-ON48257D0E.001F0CCD-48257D0E.001F38A3@zte.com.cn
State Changes Requested
Delegated to: Wolfgang Denk
Headers show

Commit Message

xu.xing1@zte.com.cn July 7, 2014, 5:39 a.m. UTC
when I use yaffs2 with inband-tags, the file always miss some part which 
filled with 0s. 

It prints 'yaffs: Chunk -1 not found zero instead' when ytrace is 0x800. 

I found out mtd_block_markbad & mtd_block_isbad parameter is wrong. 

In file fs\yaffs2\yaffs_guts.c, line 4658 to 4664? 

        /* Sort out space for inband tags, if required */ 
        if (dev->param.inband_tags) 
                dev->data_bytes_per_chunk = 
                    dev->param.total_bytes_per_chunk - 
                    sizeof(struct yaffs_packed_tags2_tags_only); 
        else 
                dev->data_bytes_per_chunk = 
dev->param.total_bytes_per_chunk; 

In inband_tags mode, data_bytes_per_chunk is not page aligned, 

so in file fs\yaffs2\yaffs_mtdif2.c, line 182 to 184 and line 201 to 203, 

        mtd_block_markbad(mtd, 
                               blockNo * dev->param.chunks_per_block * 
                               dev->data_bytes_per_chunk); 

        mtd_block_isbad(mtd, 
                             blockNo * dev->param.chunks_per_block * 
                             dev->data_bytes_per_chunk); 

the 2nd para is not correct but small. 

My patch followed, 

--------------------------------------------------------
ZTE Information Security Notice: The information contained in this mail (and any attachment transmitted herewith) is privileged and confidential and is intended for the exclusive use of the addressee(s).  If you are not an intended recipient, any disclosure, reproduction, distribution or other dissemination or use of the information contained is strictly prohibited.  If you have received this mail in error, please delete it and notify us immediately.

Comments

Wolfgang Denk July 7, 2014, 12:09 p.m. UTC | #1
Dear xu.xing1@zte.com.cn,

In message <OF377CF5DC.91728031-ON48257D0E.001F0CCD-48257D0E.001F38A3@zte.com.cn> you wrote:
> 
> when I use yaffs2 with inband-tags, the file always miss some part which 
> filled with 0s. 
> 
> It prints 'yaffs: Chunk -1 not found zero instead' when ytrace is 0x800. 
> 
> I found out mtd_block_markbad & mtd_block_isbad parameter is wrong. 
> 
> In file fs\yaffs2\yaffs_guts.c, line 4658 to 4664? 
> 
>         /* Sort out space for inband tags, if required */ 
>         if (dev->param.inband_tags) 
>                 dev->data_bytes_per_chunk = 
>                     dev->param.total_bytes_per_chunk - 
>                     sizeof(struct yaffs_packed_tags2_tags_only); 
>         else 
>                 dev->data_bytes_per_chunk = 
> dev->param.total_bytes_per_chunk; 
> 
> In inband_tags mode, data_bytes_per_chunk is not page aligned, 
> 
> so in file fs\yaffs2\yaffs_mtdif2.c, line 182 to 184 and line 201 to 203, 
> 
>         mtd_block_markbad(mtd, 
>                                blockNo * dev->param.chunks_per_block * 
>                                dev->data_bytes_per_chunk); 
> 
>         mtd_block_isbad(mtd, 
>                              blockNo * dev->param.chunks_per_block * 
>                              dev->data_bytes_per_chunk); 
> 
> the 2nd para is not correct but small. 
> 
> My patch followed, 

Thanks for analyzing the problem.

Please see [1] for the requirements how to format a patch.  Please
make sure to provide a descriptive commit message, and don't forget
your Signed-off-by: line.

Please also check if this fix is still needed with the updated MTD
code as posted by Heiko Schocher [2].  If yes, then I suggest you
rebase your fix against Heiko's code base.

Thanks.

[1] http://www.denx.de/wiki/view/U-Boot/Patches#General_Patch_Submission_Rules
[2] http://article.gmane.org/gmane.comp.boot-loaders.u-boot/189358

Best regards,

Wolfgang Denk
diff mbox

Patch

diff -uN a/fs/yaffs2/yaffs_mtdif2.c b/fs/yaffs2/yaffs_mtdif2.c 
--- a/fs/yaffs2/yaffs_mtdif2.c 
+++ b/fs/yaffs2/yaffs_mtdif2.c 
@@ -181,7 +181,7 @@  
         retval = 
             mtd_block_markbad(mtd, 
                                blockNo * dev->param.chunks_per_block * 
-                               dev->data_bytes_per_chunk); 
+                               dev->param.total_bytes_per_chunk); 
  
         if (retval == 0) 
                 return YAFFS_OK; 
@@ -200,7 +200,7 @@  
         retval = 
             mtd_block_isbad(mtd, 
                              blockNo * dev->param.chunks_per_block * 
-                             dev->data_bytes_per_chunk); 
+                             dev->param.total_bytes_per_chunk); 
  
         if (retval) { 
                 yaffs_trace(YAFFS_TRACE_MTD, "block is bad");