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

xu.xing1 at zte.com.cn xu.xing1 at zte.com.cn
Mon Jul 7 07:39:36 CEST 2014


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, 

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"); 
--------------------------------------------------------
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.


More information about the U-Boot mailing list