• Artem Bityutskiy's avatar
    UBIFS: fix GC LEB recovery · 6fb4374f
    Artem Bityutskiy authored
    UBIFS tries to alway have an LEB reserved for GC, and stores it
    in c->gc_lnum. Besides, there is GC head which points to the current
    GC head LEB.
    
    In case of an unclean power cut, what may happen is that the GC head
    was switched to the reserved GC LEB (c->gc_lnum), but a new reserved
    GC LEB was not created yet. So, after an unclean reboot we may have
    no reserved GC LEB, and we need to find a new LEB for this.
    
    To do this, we find a dirty LEB which can fit the current GC head,
    move the data, unmap this dirty LEB, and it becomes our reserved GC
    LEB.
    
    However, if we cannot find a dirty enough LEB, we return failure,
    which is wrong, because we still can have free LEBs to use for
    the reserved GC LEB. This patch fixes the issue.
    
    This patch also fixes few typos in comments, which were spotted by
    aspell.
    
    Note, this patch fixes a real issue
    
    [   14.328117] UBIFS: recovery needed
    [   53.941378] UBIFS error (pid 462): ubifs_rcvry_gc_commit: could not find a dirty LEB
    [   89.606399] UBIFS: recovery completed
    [   89.609329] UBIFS assert failed in mount_ubifs at 1358 (pid 462)
    [   89.616165] [<c0026144>] (unwind_backtrace+0x0/0xe4) from [<c0125ce4>] (ubifs_fill_super+0x11d0/0x1c4c)
    [   89.625930] [<c0125ce4>] (ubifs_fill_super+0x11d0/0x1c4c) from [<c0126910>] (ubifs_get_sb+0x1b0/0x354)
    [   89.635696] [<c0126910>] (ubifs_get_sb+0x1b0/0x354) from [<c008a50c>] (vfs_kern_mount+0x50/0xe0)
    [   89.644485] [<c008a50c>] (vfs_kern_mount+0x50/0xe0) from [<c008a5e0>] (do_kern_mount+0x34/0xdc)
    [   89.653274] [<c008a5e0>] (do_kern_mount+0x34/0xdc) from [<c00a29d8>] (do_mount+0x148/0x7cc)
    [   89.662063] [<c00a29d8>] (do_mount+0x148/0x7cc) from [<c00a30f4>] (sys_mount+0x98/0xc8)
    [   89.670852] [<c00a30f4>] (sys_mount+0x98/0xc8) from [<c0021f40>] (ret_fast_syscall+0x0/0x28)
    
    which was reported here:
    http://article.gmane.org/gmane.linux.drivers.mtd/29923
    by Alexander Pazdnikov <pazdnikov@list.ru>
    Reported-by: default avatarAlexander Pazdnikov <pazdnikov@list.ru>
    Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
    Reviewed-by: default avatarAdrian Hunter <adrian.hunter@nokia.com>
    6fb4374f
recovery.c 38.5 KB