• Zhe Li's avatar
    jffs2: fix jffs2 mounting failure · a68005a3
    Zhe Li authored
    Thanks for the advice mentioned in the email.
    This is my v3 patch for this problem.
    
    Mounting jffs2 on nand flash will get message "failed: I/O error"
    with the steps listed below.
    1.umount jffs2
    2.erase nand flash
    3.mount jffs2 on it (this mounting operation will be successful)
    4.do chown or chmod to the mount point directory
    5.umount jffs2
    6.mount jffs2 on nand flash
    After step 6, we will get message "mount ... failed: I/O error".
    
    Typical image of this problem is like:
    Empty space found from 0x00000000 to 0x008a0000
    Inode node at xx, totlen 0x00000044, #ino 1, version 1, isize 0...
    
    The reason for this mounting failure is that at the end of function
    jffs2_scan_medium(), jffs2 will check the used_size and some info
    of nr_blocks.If conditions are met, it will return -EIO.
    
    The detail is that, in the steps listed above, step 4 will write
    jffs2_raw_inode into flash without jffs2_raw_dirent, which will
    cause that there are some jffs2_raw_inode but no jffs2_raw_dirent
    on flash. This will meet the condition at the end of function
    jffs2_scan_medium() and return -EIO if we umount jffs2 and mount it
    again.
    
    We notice that jffs2 add the value of c->unchecked_size if we find
    an inode node while mounting. And jffs2 will never add the value of
    c->unchecked_size in other situations. So this patch add one more
    condition about c->unchecked_size of the judgement to fix this problem.
    Signed-off-by: default avatarZhe Li <lizhe67@huawei.com>
    Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
    a68005a3
scan.c 35.3 KB