
Hello Martin,
Am 12.01.2018 um 20:03 schrieb Martin Townsend:
From d35b7ea298fbd6c9d08b1b7132d43b9289d2b914 Mon Sep 17 00:00:00 2001
From: Martin Townsend mtownsend1973@gmail.com Date: Fri, 12 Jan 2018 18:59:23 +0000 Subject: [PATCH] ubi: Fix filesystem corruption on detach when fastmap enabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit
When detaching using "ubi detach" it calls ubi_detach_mtd_dev which calls ubi_update_fastmap twice when fastmap is enabled. The second invocation was corrupting the ubifs as it was called after uif_close. Moved all calls to ubi_wl_close before uif_close.
Signed-off-by: Martin Townsend mtownsend1973@gmail.com
drivers/mtd/ubi/build.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index baf4e2d..795ea34 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -1082,9 +1082,9 @@ out_debugfs: out_uif: get_device(&ubi->dev); ubi_assert(ref);
- ubi_wl_close(ubi); uif_close(ubi); out_detach:
- ubi_wl_close(ubi); ubi_free_internal_volumes(ubi); vfree(ubi->vtbl); out_free:
@@ -1161,9 +1161,9 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway) get_device(&ubi->dev);
ubi_debugfs_exit_dev(ubi);
- ubi_wl_close(ubi); uif_close(ubi);
- ubi_wl_close(ubi); ubi_free_internal_volumes(ubi); vfree(ubi->vtbl); put_mtd_device(ubi->mtd);
Could you please try the following patch:
diff --git a/drivers/mtd/ubi/fastmap-wl.c b/drivers/mtd/ubi/fastmap-wl.c index a33d4063e0..2923d21836 100644 --- a/drivers/mtd/ubi/fastmap-wl.c +++ b/drivers/mtd/ubi/fastmap-wl.c @@ -339,8 +339,6 @@ static void ubi_fastmap_close(struct ubi_device *ubi)
#ifndef __UBOOT__ flush_work(&ubi->fm_work); -#else - update_fastmap_work_fn(ubi); #endif return_unused_pool_pebs(ubi, &ubi->fm_pool); return_unused_pool_pebs(ubi, &ubi->fm_wl_pool);
Your problem is (I think) because U-Boot Code accidentially calls update_fastmap_work_fn(ubi), but we do not need it here anymore, as U-Boot does all UBI work immediately.
bye, Heiko