ubi: Make recover_peb power cut aware
authorRichard Weinberger <richard@nod.at>
Mon, 20 Jun 2016 22:31:50 +0000 (00:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Jul 2016 16:47:33 +0000 (09:47 -0700)
commitca8a32b2170621da0bb1807470917cf30a2af2c8
tree5e9860b39f55f2d1a097ee6ca2385c4372525504
parent69eab50dedd0c74f29c754f7fad190ce28a0b22f
ubi: Make recover_peb power cut aware

commit 972228d87445dc46c0a01f5f3de673ac017626f7 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: Jörg Pfähler <pfaehler@isse.de>
Reviewed-by: Jörg Pfähler <pfaehler@isse.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/ubi/eba.c