• Zhe Li's avatar
    jffs2: Fix GC exit abnormally · 9afc9a8a
    Zhe Li authored
    The log of this problem is:
    jffs2: Error garbage collecting node at 0x***!
    jffs2: No space for garbage collection. Aborting GC thread
    
    This is because GC believe that it do nothing, so it abort.
    
    After going over the image of jffs2, I find a scene that
    can trigger this problem stably.
    The scene is: there is a normal dirent node at summary-area,
    but abnormal at corresponding not-summary-area with error
    name_crc.
    
    The reason that GC exit abnormally is because it find that
    abnormal dirent node to GC, but when it goes to function
    jffs2_add_fd_to_list, it cannot meet the condition listed
    below:
    
    if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name))
    
    So no node is marked obsolete, statistical information of
    erase_block do not change, which cause GC exit abnormally.
    
    The root cause of this problem is: we do not check the
    name_crc of the abnormal dirent node with summary is enabled.
    
    Noticed that in function jffs2_scan_dirent_node, we use
    function jffs2_scan_dirty_space to deal with the dirent
    node with error name_crc. So this patch add a checking
    code in function read_direntry to ensure the correctness
    of dirent node. If checked failed, the dirent node will
    be marked obsolete so GC will pass this node and this
    problem will be fixed.
    
    Cc: <stable@vger.kernel.org>
    Signed-off-by: default avatarZhe Li <lizhe67@huawei.com>
    Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
    9afc9a8a
readinode.c 43.2 KB