• Richard Weinberger's avatar
    ubi: Make recover_peb power cut aware · bedbc047
    Richard Weinberger authored
    commit 972228d8 upstream.
    
    recover_peb() was never power cut aware,
    if a power cut happened right after writing the VID header
    upon next attach UBI would blindly use the new partial written
    PEB and all data from the old PEB is lost.
    
    In order to make recover_peb() power cut aware, write the new
    VID with a proper crc and copy_flag set such that the UBI attach
    process will detect whether the new PEB is completely written
    or not.
    We cannot directly use ubi_eba_atomic_leb_change() since we'd
    have to unlock the LEB which is facing a write error.
    Reported-by: default avatarJörg Pfähler <pfaehler@isse.de>
    Reviewed-by: default avatarJörg Pfähler <pfaehler@isse.de>
    Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
    [bwh: Backported to 3.2:
     - Adjust context
     - Use next_sqnum() instead of ubi_next_sqnum()
     - Use ubi_device::peb_buf1 instead of ubi_device::peb_buf
     - No need to unlock ubi->fm_eba_sem on error]
    Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
    bedbc047
eba.c 36.3 KB