UBI: Fastmap: Fix race after ubi_wl_get_peb()
authorRichard Weinberger <richard@nod.at>
Mon, 10 Nov 2014 15:27:10 +0000 (16:27 +0100)
committerRichard Weinberger <richard@nod.at>
Thu, 26 Mar 2015 21:46:01 +0000 (22:46 +0100)
commit8fb2a514780eee48602424a86e3cd72d3f1bdfb2
tree2c5c3bced155af20a7a27a2b368bc7c1df5586fa
parentad3d6a05ee45eebf68ff08da0d3f86251b530a27
UBI: Fastmap: Fix race after ubi_wl_get_peb()

ubi_wl_get_peb() returns a fresh PEB which can be used by
user of UBI. Due to the pool logic fastmap will correctly
map this PEB upon attach time because it will be scanned.

If a new fastmap is written (due to heavy parallel io)
while the before the fresh PEB is assigned to the EBA table
it will not be scanned as it is no longer in the pool.
So, the race window exists between ubi_wl_get_peb()
and the EBA table assignment.
We have to make sure that no new fastmap can be written
while that.

To ensure that ubi_wl_get_peb() will grab ubi->fm_sem in read mode
and the user of ubi_wl_get_peb() has to release it after the PEB
got assigned.

Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/eba.c
drivers/mtd/ubi/wl.c
This page took 0.02683 seconds and 5 git commands to generate.