[20/23] UBI: Fastmap: Write fastmap only at detach time if none is present

Submitted by Richard Weinberger on June 1, 2012, 3:16 p.m.

Details

Message ID 1338563804-85990-21-git-send-email-richard@nod.at
State New, archived
Headers show

Commit Message

Richard Weinberger June 1, 2012, 3:16 p.m.
Write a fastmap only if currently no fastmap is present on the FLASH.
Also write it after the UBI thread has stopped.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 drivers/mtd/ubi/build.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 4a8688a..2acfe5b 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -1045,7 +1045,6 @@  int ubi_detach_mtd_dev(int ubi_num, int anyway)
 	ubi_assert(ubi_num == ubi->ubi_num);
 	ubi_notify_all(ubi, UBI_VOLUME_REMOVED, NULL);
 	dbg_msg("detaching mtd%d from ubi%d", ubi->mtd->index, ubi_num);
-	ubi_update_fastmap(ubi);
 
 	/*
 	 * Before freeing anything, we have to stop the background thread to
@@ -1054,6 +1053,10 @@  int ubi_detach_mtd_dev(int ubi_num, int anyway)
 	if (ubi->bgt_thread)
 		kthread_stop(ubi->bgt_thread);
 
+	/* If no fastmap is present on the FLASH write one. */
+	if (!ubi->fm)
+		ubi_update_fastmap(ubi);
+
 	/*
 	 * Get a reference to the device in order to prevent 'dev_release()'
 	 * from freeing the @ubi object.